ir: auto-deref *Self when invoking a Closure-typed field (issue-0035)
When lowering `self.cb()` from inside a method whose receiver is *Self, the field-access path passed the receiver pointer (not the aggregate) to `structGet`, which then produced `call void undef(ptr undef)` at the LLVM level — undefined at runtime, corrupted adjacent globals when it transferred control to a garbage pointer. Auto-load through the pointer first so structGet receives a real aggregate. Discovered while building the new AndroidPlatform's `run_frame_loop` — calling the stored frame closure as `self.frame_closure()` zeroed out adjacent globals because the undef call jumped into random memory. Added examples/100-closure-field-call-via-self-ptr.sx as the locked-in regression: both direct (`self.cb()`) and hoisted (`fn := self.cb; fn();`) forms must yield identical IR + behavior. 86/86 regression tests pass.
This commit is contained in:
1
tests/expected/100-closure-field-call-via-self-ptr.exit
Normal file
1
tests/expected/100-closure-field-call-via-self-ptr.exit
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
1
tests/expected/100-closure-field-call-via-self-ptr.txt
Normal file
1
tests/expected/100-closure-field-call-via-self-ptr.txt
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user