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:
@@ -9631,6 +9631,17 @@ pub const Lowering = struct {
|
||||
if (param.is_comptime and call_arg_idx <= call_node.args.len) {
|
||||
pack_arg_name = param.name;
|
||||
pack_arg_slice = call_node.args[call_arg_idx..];
|
||||
// Stamp each pack arg with the caller's source so the
|
||||
// body's typed `args[i]` substitution (via packArgNodeAt,
|
||||
// lowered under the defining-module pin set below) resolves
|
||||
// its bare names in the CALLER's visibility context — the
|
||||
// same treatment the fixed comptime params get below.
|
||||
// Without it a caller-owned helper passed to an imported
|
||||
// metaprogram (`std.print("{}", caller_fn())`) resolves
|
||||
// under the callee's module and is reported "not visible".
|
||||
for (call_node.args[call_arg_idx..]) |pack_arg| {
|
||||
self.stampCallerSource(pack_arg);
|
||||
}
|
||||
}
|
||||
break; // variadic is always the last param
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user