Files
sx/examples/packs/0507-packs-pack-mono-dedup.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
1.0 KiB
Plaintext

// Variadic heterogeneous type packs — step 2b: per-call-shape
// monomorphisation. Each unique call signature gets ONE mono fn;
// repeat calls with the same signature share it. The runtime output
// confirms correct semantics; the IR (visible via `sx ir`) shows
// the distinct mono symbols:
//
// call @count__pack(ctx)
// call @count__pack_i64(ctx, 1)
// call @count__pack_i64(ctx, 2) ← shares with the 1-arg i64 call
// call @count__pack_i64_i64_i64(ctx, 1, 2, 3)
// call @count__pack_string_bool(ctx, ..)
//
// Before step 2b, each call inlined a fresh copy of the body into
// main's basic block — no shared symbols, IR size grew linearly in
// call sites. After 2b, distinct shapes get distinct functions,
// repeats share, IR scales with unique shapes.
#import "modules/std.sx";
count :: (..$args) -> i64 => args.len;
main :: () -> i32 {
a := count();
b := count(1);
c := count(2);
d := count(1, 2, 3);
e := count("x", true);
print("{} {} {} {} {}\n", a, b, c, d, e);
return 0;
}