wcc/ww: def-dim array slice-arg default-hi takes the length from the type table

Passing buf[1:] of a [MAX]u8 as a call arg dropped the default-hi
length (the arg-push N_SLICE arms' fallback covered only named-alias
bases). Same type-table resolve at pushargsrev local+global. This
closes the def-dim dimension family by construction: every N_INTLIT-
keyed dim consumer (cgslice, cgdot, letemitsize, arg-push) now
carries the tichase().alen fallback — grep-proven, no consumer
remains. Fourth member surfaced by the family grep.
This commit is contained in:
2026-06-13 01:56:01 +09:00
parent b97be7301f
commit ffe37deaee
5 changed files with 252 additions and 18 deletions

View File

@@ -641,10 +641,21 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
if (tn != nil) {
if (tn.kind == nkind.N_TARRAY) {
let lenn: *node = tn.rhs;
if (lenn != nil) {
if (lenn.kind == nkind.N_INTLIT) {
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
emitline("\tMOVQ\t$");
emituint(lenn.uval);
emitline(", AX\n");
} else {
// #56: def/const dim — resolve from the stamped
// array tinfo (rule-13). The #60 bu60 arm below
// covers only NAMED-alias bases (tn.kind ==
// N_TNAME); a plain `[MAX]u8` base reaches here
// with a non-N_INTLIT dim and dropped the
// default-hi entirely. cstage reads bu->alen.
let abt: *tinfo = tichase(tn.type_: *tinfo);
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
emitline("\tMOVQ\t$");
emituint(lenn.uval);
emitint(abt.alen: i64);
emitline(", AX\n");
};
};
@@ -677,10 +688,18 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
} else { if (globaltn != nil) {
if (globaltn.kind == nkind.N_TARRAY) {
let lenn: *node = globaltn.rhs;
if (lenn != nil) {
if (lenn.kind == nkind.N_INTLIT) {
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
emitline("\tMOVQ\t$");
emituint(lenn.uval);
emitline(", AX\n");
} else {
// #56: def/const dim on a global array base —
// resolve from the stamped array tinfo (rule-13),
// twin of the local arg-push arm above.
let abt: *tinfo = tichase(globaltn.type_: *tinfo);
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
emitline("\tMOVQ\t$");
emituint(lenn.uval);
emitint(abt.alen: i64);
emitline(", AX\n");
};
};