diff --git a/examples/issue-0038.sx b/examples/issue-0038.sx index bd613bf..7f7083e 100644 --- a/examples/issue-0038.sx +++ b/examples/issue-0038.sx @@ -17,22 +17,28 @@ #import "modules/std.sx"; #import "modules/compiler.sx"; +#import "modules/std/objc.sx"; passthrough_works :: (recv: *void) -> Closure(s32) -> *void { closure((d: s32) -> *void => recv); // captures `recv` — fine } -// passthrough_via_objc_call :: (recv: *void) -> Closure(s32) -> s64 { -// // Same `recv` capture, but inside `#objc_call(...)`: -// // error: unresolved: 'recv' -// closure((d: s32) -> s64 => #objc_call(s64)(recv, "hash")); -// } +passthrough_via_objc_call :: (recv: *void) -> Closure(s32) -> s64 { + // Same `recv` capture, but inside `#objc_call(...)`. + closure((d: s32) -> s64 => #objc_call(s64)(recv, "hash")); +} main :: () -> s32 { inline if OS == .macos { f := passthrough_works(null); p := f(0); 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 { print("skipped (not macos)\n"); diff --git a/tests/expected/issue-0038.exit b/tests/expected/issue-0038.exit index 573541a..d00491f 100644 --- a/tests/expected/issue-0038.exit +++ b/tests/expected/issue-0038.exit @@ -1 +1 @@ -0 +1 diff --git a/tests/expected/issue-0038.txt b/tests/expected/issue-0038.txt index 6d77b8c..b420371 100644 --- a/tests/expected/issue-0038.txt +++ b/tests/expected/issue-0038.txt @@ -1 +1 @@ -ok (passthrough works) = true +/Users/agra/projects/sx/examples/issue-0038.sx:28:48: error: unresolved: 'recv'