wcc/ww: def-dim array .len field-reads resolve the dimension from the type table

buf.len on a [MAX]u8 returned 0 — the cgdot len arms (local/global/
def) and letemitsize only read an N_INTLIT dimension. Route a
non-literal dimension through tichase().alen (the #21 fix mirrored
into the field-read consumers; .ptr arms are dim-independent).
Review-era task #56.
This commit is contained in:
2026-06-13 01:52:42 +09:00
parent faf1a2908b
commit b97be7301f
6 changed files with 308 additions and 30 deletions

View File

@@ -1004,8 +1004,17 @@ fn letemitsize(c: *cgen, d: *node) i32 = {
let lenn: *node = t.rhs;
let elemn: *node = t.lhs;
let alen: i32 = 1;
if (lenn != nil) {
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i32; };
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
alen = lenn.uval: i32;
} else {
// #56: def/const dim — resolve from the stamped array
// tinfo (rule-13), the letemitsize twin of the cgdot
// .len fix. Pre-fix a non-N_INTLIT dim defaulted alen=1
// → array global mis-sized (one element's worth).
let abt: *tinfo = tichase(t.type_: *tinfo);
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
alen = abt.alen: i32;
};
};
let esz: i32 = 8;
if (elemn != nil) {