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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user