Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
18 lines
868 B
Plaintext
18 lines
868 B
Plaintext
// Regression (issue 0060): a closure LITERAL passed directly as a bare
|
|
// function-type argument `(T) -> U` and then called inside the callee. The
|
|
// closure's underlying function takes a hidden env arg that a bare fn-ptr slot
|
|
// doesn't pass, so the compiler bridges a capture-free closure to the bare ABI
|
|
// with a generated adapter. Both block and arrow bodies. (The working contrast
|
|
// where the param is a `Closure(...)` type is examples/0302.)
|
|
|
|
#import "modules/std.sx";
|
|
|
|
apply :: (f: (i64) -> i64) -> i64 { return f(5); }
|
|
twice :: (f: (i64) -> i64, x: i64) -> i64 { return f(f(x)); }
|
|
|
|
main :: () {
|
|
print("block={}\n", apply(closure((x: i64) -> i64 { return x * 2; }))); // 10
|
|
print("arrow={}\n", apply(closure((x: i64) -> i64 => x * 2))); // 10
|
|
print("twice={}\n", twice(closure((x: i64) -> i64 => x + 3), 1)); // ((1+3)+3) = 7
|
|
}
|