A closure VALUE (a pre-bound variable) flowing into a bare (T)->U slot was passed unsoundly: the bare ABI calls fn_ptr(ctx, args) with no env channel, so the closure's underlying fn (which takes an env slot) had its env dropped and args shifted — UB for a matching ABI, a wrong-tuple read for the non-failable->failable widening (returned -1), and a segfault when the closure captured. coerceToType now rejects a .closure -> .function coercion with a diagnostic pointing at the idiom (pass the literal directly, which gets the static adapter, or type the parameter Closure(...) so the env is carried). Closure LITERALS are unaffected — lowerLambda pre-adapts them to a .function-typed value before coercion. Regression: 1045-errors-closure-var-bare-slot-reject.sx.
18 lines
1.3 KiB
Plaintext
18 lines
1.3 KiB
Plaintext
error: a closure value cannot be passed as a bare function-pointer `(...) -> ...` — its environment can't be carried across the bare ABI; pass the closure literal directly at the call site, or declare the parameter type as `Closure(...)`
|
|
--> /Users/agra/projects/sx/examples/1045-errors-closure-var-bare-slot-reject.sx:23:10
|
|
|
|
|
23 | _ := bare(inc, 9); // reject: closure value → bare slot
|
|
| ^^^^^^^^^^^^
|
|
|
|
error: a closure value cannot be passed as a bare function-pointer `(...) -> ...` — its environment can't be carried across the bare ABI; pass the closure literal directly at the call site, or declare the parameter type as `Closure(...)`
|
|
--> /Users/agra/projects/sx/examples/1045-errors-closure-var-bare-slot-reject.sx:24:10
|
|
|
|
|
24 | _ := baref(inc, 9); // reject: also the ∅-widening crossing
|
|
| ^^^^^^^^^^^^^
|
|
|
|
error: a closure value cannot be passed as a bare function-pointer `(...) -> ...` — its environment can't be carried across the bare ABI; pass the closure literal directly at the call site, or declare the parameter type as `Closure(...)`
|
|
--> /Users/agra/projects/sx/examples/1045-errors-closure-var-bare-slot-reject.sx:25:10
|
|
|
|
|
25 | _ := bare(add, 9); // reject: capturing closure → bare slot
|
|
| ^^^^^^^^^^^^
|