fix(lower): stamp caller source on variadic comptime pack args [stdlib B attempt-6]

lowerComptimeCall stamped the caller's source onto fixed comptime `$`-params
so their substituted bare names resolve in the caller's visibility context,
but the variadic comptime pack branch (`..$args`) recorded the pack-arg slice
without stamping. Those nodes are later re-lowered via packArgNodeAt under the
defining-module pin, so a caller-owned helper in a formatted-arg position
(`std.print("{}", caller_fn())`) was checked against the metaprogram's module
and rejected as "not visible". Stamp every pack-arg node with the caller source,
mirroring the fixed-param treatment — completing Problem 1 for pack args.

Regression: examples/0739-modules-comptime-pack-arg-caller-context.sx
(two caller-owned s64 helpers in std.print pack positions; fail-before both
"not visible", pass-after prints "42 7"). No exemption flag, no silent default.
This commit is contained in:
agra
2026-06-07 09:31:17 +03:00
parent 8875a28641
commit 0369cb001f
5 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
// Caller-owned helpers passed as VARIADIC comptime-pack args (`..$args`) to a
// NAMESPACED imported metaprogram resolve in the CALLER's visibility context —
// not the metaprogram's defining module (regression, issue 0106 follow-up).
//
// `std.print :: ($fmt: string, ..$args)` is authored in `std.sx`; the pack args
// `caller_num()` / `caller_two()` are authored HERE in the caller. The body's
// typed `args[i]` substitution (via packArgNodeAt) lowers each pack arg under
// the metaprogram's defining-module pin, so without stamping the pack-arg nodes
// with the caller's source, the bare names `caller_num` / `caller_two` were
// wrongly checked against `std.sx` and rejected as "not visible". The fixed
// comptime param (`$fmt`) already got this treatment; this extends it to every
// node in the variadic pack. The metaprogram's OWN code (build_format / out)
// still resolves in `std.sx`, so the defining-context pin stays intact.
//
// Two pack positions lock that EVERY pack arg is stamped, not just the first.
// s64 values only — accepted by print at runtime today (no 0107/0108 coupling).
std :: #import "modules/std.sx";
caller_num :: () -> s64 { return 42; }
caller_two :: () -> s64 { return 7; }
main :: () -> s32 {
std.print("{} {}\n", caller_num(), caller_two());
return 0;
}