diff --git a/internal/wwfixture/types.ww b/internal/wwfixture/types.ww index eb713adb..a3bacb49 100644 --- a/internal/wwfixture/types.ww +++ b/internal/wwfixture/types.ww @@ -1,13 +1,13 @@ package wwfixture; def protocolversion: i32 = 1; -def corpuscount: i32 = 1749; +def corpuscount: i32 = 1750; def errorcount: i32 = 349; def compilecount: i32 = 21; def runcount: i32 = 209; -def runexitcount: i32 = 1170; -def nativecount: i32 = 3498; -def corpushash: str = "616b3e7f4fca31cb99409c58a29ac73623c997967ddd57651a1370c2c2e2be6a"; +def runexitcount: i32 = 1171; +def nativecount: i32 = 3500; +def corpushash: str = "d52fa0df91c89bf51bca70045a2dbf39d5012ac03bf687e231240dc1c5b3fc53"; type directive = enum i32 { ERROR = 0, diff --git a/selfhost/cmd/wcc/cgenutil.ww b/selfhost/cmd/wcc/cgenutil.ww index 7222b3da..60781ee5 100644 --- a/selfhost/cmd/wcc/cgenutil.ww +++ b/selfhost/cmd/wcc/cgenutil.ww @@ -5937,11 +5937,18 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *syntax.node, }; if (repeat) { let total: i32 = idx; - if (fi.tnode.rhs != nil) { + // rule 13: dim off the STAMPED array tinfo, not + // the surface node — an N_INTLIT-only read left a + // def-dimensioned [N]T field under-filled (ww-only + // silent; cstage + the tn twin read stamped alen). + let ftfill: *syntax.tinfo = tichase(fi.tnode.type_: *syntax.tinfo); + if (ftfill != nil && ftfill.kind == syntax.tykind.TY_ARRAY) { + total = ftfill.alen: i32; + } else { if (fi.tnode.rhs != nil) { if (fi.tnode.rhs.kind == syntax.nkind.N_INTLIT) { total = fi.tnode.rhs.uval: i32; }; - }; + }; }; for (idx < total) { if (mode == 1) { emitline("\tMOVQ\t"); diff --git a/test/wcc/data/defdim_field_fill/case.ww b/test/wcc/data/defdim_field_fill/case.ww new file mode 100644 index 00000000..ac5dbd3a --- /dev/null +++ b/test/wcc/data/defdim_field_fill/case.ww @@ -0,0 +1,16 @@ +//ww:run-exit 0 +// structlit `...` repeat-fill on a def-dimensioned [N]T field: the +// fill total must come off the stamped array tinfo (rule 13). The +// N_INTLIT-only surface read left elements 1..N-1 zero (ww-only). +package main; +def N: int = 4; +type holder = struct { arr: [N]i64, tail: i64 }; +export fn main() i32 = { + let h: holder = holder{ arr = [7...], tail = 9 }; + if (h.arr[0] != 7) { return 1; }; + if (h.arr[1] != 7) { return 2; }; + if (h.arr[2] != 7) { return 3; }; + if (h.arr[3] != 7) { return 4; }; + if (h.tail != 9) { return 5; }; + return 0; +};