selfhost/cmd/wcc: variadic param N_TSLICE wrap at installparams (cascade Commit 3, #25/#41)

installparams normalises `T...` p.lhs to []T so N_IDENT lookups
(s.decl.lhs) and cgen's variadic-slot synthesis see the effective
slice — mirrors cstage check.c:455 `tp->type = type_slice(c->a, pt)`
and harec check_func_type. cgendecl/cgenexpr drop the on-the-fly
slicewrap and consume p.lhs directly; cgenexpr cgcall peels the
N_TSLICE wrap when reading the element predicates / esz (Ken's
gate: cstage cgen.c:4352 `vsu->kind == TY_SLICE`), and passes
`velem` — not the wrap — into cgwidentaggedstore (cstage cgen.c
:4382). Closes the 22 N_DOT + 9 N_INDEX fires from #36 with the
cascade absorbed by e662156 (#39 arm-6 recursion). Class B "case:
not a variant of scrutinee" did NOT fire post-#39, so Commit 2
(#40 tagged_select_subtype) was not needed.
This commit is contained in:
2026-05-22 03:09:22 +09:00
parent e662156574
commit 45910ff966
5 changed files with 141 additions and 45 deletions

View File

@@ -2726,6 +2726,20 @@ fn installparams(c: *checker, params: *node) void = {
let p: *node = params;
for (p != nil) {
if (p.kind == nkind.N_PARAM) {
// Hare-style variadic `T...`: normalize p.lhs to []T so
// downstream consumers (N_IDENT exprtype lookups via
// s.decl.lhs, cgen's variadic-slot synthesis) see the
// effective slice type. Mirrors cstage check.c:455
// `tp->type = type_slice(c->a, pt)` and harec
// check_func_type. Surface-fidelity preserved: wwdump
// -a runs parser only and never reaches this mutation.
if (p.op == tkind.TK_ELLIPSIS) {
if (p.lhs != nil && p.lhs.kind != nkind.N_TSLICE) {
let sl: *node = newnode(nkind.N_TSLICE, "", 0, 0);
sl.lhs = p.lhs;
p.lhs = sl;
};
};
let nm: str = p.str;
if (nm.len > 0) {
checkmoduleshadow(c, nm, "param");