Commit 6c173be
fix(vm): partial equals() fix - pointer equality support
Partial fix for VM equality comparison bug. Adds infrastructure for
semantic equality but keeps user-defined equals() dispatch disabled.
**What This Fixes**:
- ✅ Primitive comparisons (int, string, bool) - unchanged, still work
- ✅ Pointer equality (same instance) - fast path with Arc::ptr_eq
- ✅ VoidBox/MissingBox special cases - handled correctly
- ✅ Infrastructure for eval_equals() method dispatch
**What's Still Broken**:
- ❌ User-defined equals() methods - dispatch disabled (line 61: if false)
- ❌ Box semantic equality - falls back to reference inequality
**Root Cause** (from investigation):
- Bug is NOT in eval.rs:224 (Compare instruction)
- Bug is in abi_util.rs:75 (eq_vm uses Arc::ptr_eq for ALL boxes)
- Calling exec_function_inner() from eval_cmp() causes re-entrant stack overflow
**Next Steps** (root fix required):
- Option 1: Transform `box1 == box2` → `box1.equals(box2)` at MIR level
- Option 2: Use existing BoxCall mechanism instead of Compare instruction
- Option 3: Deferred execution queue to avoid re-entrant calls
**Files Modified**:
- src/backend/mir_interpreter/helpers/eval.rs
- Added eval_equals() method (lines 23-77)
- Modified eval_cmp() to take &mut self (line 209)
- Changed Compare Eq/Ne to use eval_equals() (lines 306-307)
- Added InstanceBox, Arc imports
**Test Results**:
- ✅ Primitives: ALL PASS
- ✅ Pointer equality: PASS
- ❌ User-defined equals(): DISABLED (would stack overflow)
**Issue**: This is a PARTIAL fix. Full semantic equality requires root fix.
See: docs/development/issues/equals-stack-overflow.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 980bc2c commit 6c173be
1 file changed
Lines changed: 61 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
21 | 79 | | |
22 | 80 | | |
23 | 81 | | |
| |||
124 | 182 | | |
125 | 183 | | |
126 | 184 | | |
127 | | - | |
| 185 | + | |
128 | 186 | | |
129 | 187 | | |
130 | 188 | | |
| |||
221 | 279 | | |
222 | 280 | | |
223 | 281 | | |
224 | | - | |
225 | | - | |
| 282 | + | |
| 283 | + | |
226 | 284 | | |
227 | 285 | | |
228 | 286 | | |
| |||
0 commit comments