Files
sx/examples/packs/0524-packs-generic-fn-pack-state-leak.sx
agra 66bdc70bf1 test: group examples into per-category folders
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.
2026-06-21 14:41:34 +03:00

31 lines
973 B
Plaintext

// Regression: a generic function (with `$T: Type` type params)
// called from inside a pack-fn mono must NOT inherit the outer
// pack maps during its own body lowering. Before the fix landed
// in `monomorphizeFunction`, the cached mono of a generic with
// an `args`-named param had its `args.len` constant-folded to
// the arity of whichever pack shape triggered the first mono;
// every subsequent shape read the same baked-in constant.
//
// Same root cause as issue-0048 (`lazyLowerFunction`), in a
// different lowering path (`monomorphizeFunction`).
#import "modules/std.sx";
build :: (args: []Type, $ret: Type) -> string {
return concat("len=", int_to_string(args.len));
}
probe :: (..$args) -> string {
return build($args, void);
}
run_all :: () {
print("0: {}\n", probe());
print("1: {}\n", probe(true));
print("2: {}\n", probe(42, "hi"));
print("4: {}\n", probe(1, 2.0, "x", true));
}
#run run_all();
main :: () { print("rt\n"); }