issue-0038: xfail repro — recv capture inside #objc_call
Uncomments the second passthrough case in `examples/issue-0038.sx`
that captures `recv` from the enclosing function into a closure body
that uses it inside `#objc_call(s64)(recv, "hash")`. Current behavior
is a hard error from the name-resolution pass:
examples/issue-0038.sx:28:48: error: unresolved: 'recv'
Snapshot locks the failure in (exit 1 + that error message) so the
next commit can flip it to passing without ambiguity. Per the FFI
cadence rule this is a test-add (xfail); the make-green follow-up
adds the missing recursion arm in `lower.zig`'s `collectCaptures` for
`.ffi_intrinsic_call` nodes.
This commit is contained in:
@@ -17,22 +17,28 @@
|
|||||||
|
|
||||||
#import "modules/std.sx";
|
#import "modules/std.sx";
|
||||||
#import "modules/compiler.sx";
|
#import "modules/compiler.sx";
|
||||||
|
#import "modules/std/objc.sx";
|
||||||
|
|
||||||
passthrough_works :: (recv: *void) -> Closure(s32) -> *void {
|
passthrough_works :: (recv: *void) -> Closure(s32) -> *void {
|
||||||
closure((d: s32) -> *void => recv); // captures `recv` — fine
|
closure((d: s32) -> *void => recv); // captures `recv` — fine
|
||||||
}
|
}
|
||||||
|
|
||||||
// passthrough_via_objc_call :: (recv: *void) -> Closure(s32) -> s64 {
|
passthrough_via_objc_call :: (recv: *void) -> Closure(s32) -> s64 {
|
||||||
// // Same `recv` capture, but inside `#objc_call(...)`:
|
// Same `recv` capture, but inside `#objc_call(...)`.
|
||||||
// // error: unresolved: 'recv'
|
closure((d: s32) -> s64 => #objc_call(s64)(recv, "hash"));
|
||||||
// closure((d: s32) -> s64 => #objc_call(s64)(recv, "hash"));
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
main :: () -> s32 {
|
main :: () -> s32 {
|
||||||
inline if OS == .macos {
|
inline if OS == .macos {
|
||||||
f := passthrough_works(null);
|
f := passthrough_works(null);
|
||||||
p := f(0);
|
p := f(0);
|
||||||
print("ok (passthrough works) = {}\n", p == null);
|
print("ok (passthrough works) = {}\n", p == null);
|
||||||
|
|
||||||
|
// After the fix, capture in an FfiIntrinsicCall arg list works.
|
||||||
|
ns_object := objc_getClass("NSObject".ptr);
|
||||||
|
g := passthrough_via_objc_call(ns_object);
|
||||||
|
h := g(0);
|
||||||
|
print("ok (passthrough via #objc_call) = {}\n", h != 0);
|
||||||
}
|
}
|
||||||
inline if OS != .macos {
|
inline if OS != .macos {
|
||||||
print("skipped (not macos)\n");
|
print("skipped (not macos)\n");
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0
|
1
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
ok (passthrough works) = true
|
/Users/agra/projects/sx/examples/issue-0038.sx:28:48: error: unresolved: 'recv'
|
||||||
|
|||||||
Reference in New Issue
Block a user