Files
sx/examples/0726-modules-flat-same-name-variadic.sx
agra 8f9c00dcdb fix(lower): resolved author drives variadic packing in bare call [0102c F1]
Attempt-2 fix for the F1 review finding. After `resolveBareCallee` picks a
shadowed same-name author's FuncId at a normal call site, the call path still
re-fetched the FIRST-WINS function AST by name to drive variadic argument
packing. When the resolved (shadow) author's variadic shape differs from the
first-wins author's, arguments were packed against the WRONG signature — a
fixed-arity shadow packed as if variadic, or a variadic shadow not packed at
all — producing IR with the wrong argument count (LLVM verification failure).

The `.func` arm now carries the resolved `*FnDecl` alongside its FuncId
(`BareCallee.func: ResolvedAuthor`), so `packVariadicCallArgs` reads THE
resolved author's signature. The rest of the arm already used the resolved
FuncId's IR function (ret/params/ctx/coercion), so the callee now has one
source of truth in the whole call lowering — no re-fetch by name after
resolution. Default-arg / closure / UFCS / comptime *sites* remain first-wins
(fix-0102d); `expandCallDefaults` runs before resolution and is a default site.

Regression: examples/0726-modules-flat-same-name-variadic — two flat file
imports each author `combine` and `pick` with OPPOSITE variadic shapes (a.sx
fixed `combine` / variadic `pick`; b.sx variadic `combine` / fixed `pick`).
Each module's bare call must pack against ITS OWN author. Fails on the pre-fix
re-lookup (LLVM "Incorrect number of arguments passed to called function" for
both `combine.1` and `pick.2`); passes after.

Gate: zig build, zig build test (400/400), bash tests/run_examples.sh
(463 passed) all green. Matrix 0722-0725/0727 unchanged; single-author / local
resolution byte-for-byte unchanged (the `.func` arm never runs for them).
2026-06-06 14:28:00 +03:00

24 lines
1.1 KiB
Plaintext

// fix-0102c F1 (issue 0102): two flat FILE imports each author same-name free
// functions whose VARIADIC SHAPE differs. `combine` is fixed-arity in a.sx
// (the first-wins winner) but variadic in b.sx (the shadow); `pick` is the
// reverse. Each module's bare call must pack arguments against ITS OWN
// author's signature — not the first-wins author's. Pre-fix the call path
// re-fetched the first-wins AST by name to drive variadic packing, so b.sx's
// variadic `combine` was packed as if fixed (and its fixed `pick` as if
// variadic) → wrong lowering. Regression for the F1 review finding.
#import "modules/std.sx";
#import "0726-modules-flat-same-name-variadic/a.sx";
#import "0726-modules-flat-same-name-variadic/b.sx";
report :: (label: string, ok: bool) {
if ok { print("{}: ok\n", label); } else { print("{}: FAIL\n", label); }
}
main :: () -> s32 {
report("from_a combine fixed", from_a_combine() == 30);
report("from_b combine variadic", from_b_combine() == 10);
report("from_a pick variadic", from_a_pick() == 6);
report("from_b pick fixed", from_b_pick() == 5);
0
}