Tag v3-fix-nested-arrays. Main suite 108/108; QbeGen still compiles
clean under V3; tools/m2make 18/18.
Two failures surfaced by M2make (documented in
tools/m2make/README.md), which forced its portable core onto a
"flat 1-D arrays only" subset:
Sum(m[1]), segfaulted;a[i][j] / HIGH(a[i]) patterns in M2makeOS could not be used.Fact's Design branch loaded array-typed designators a second time.
Design already materialises the array value for array-typed suffixes:
the [i] index handler and the .field handler both emit ElemLoad
(load the sub-descriptor pointer) when the element type is an array.
Fact then did ElemLoad again, so the row pointer was replaced by its
first word (the element count), which was passed on as an address:
%t129 =l loadl %t128 ; row descriptor address (correct, from Design)
%t130 =l loadl %t129 ; extra load: dereferences the row -> count
call $Sum_0(l 0, l %t130)
compiler/src/M2.atg (Fact, Design branch): treat ClArray like
ClRecord / ClSet / ClClass — an array designator's value is its
address, so CopyOp(qd, q) instead of ElemLoad(qd, dt, q).
Sum(m[1]) went from SIGSEGV (139) to the expected value (15),
confirmed by reverting and re-applying the one-line change.compiler/tests/t_nestidx.mod (exit 42) covers
a[i][j] loads and stores, the comma form a[i, j],
HIGH(row) via Sum, and passing rows to an open-array formal.M2makeOS pattern (argTab[i][k], HIGH(argTab[i]),
CopyArg(s, argTab[argN])) now compiles and runs.QbeGen.def/.mod still compile clean under V3 (0 errors).a[i][j] loads"A minimal a[i][j] load/store parsed and ran correctly even with the
fix reverted, so no separate rejection was reproducible; the
open-array-actual case is the one that definitely miscompiled. The
one-line change above is the common fix for the nested-array-element
value path.
compiler/src/M2.atg, compiler/tests/t_nestidx.mod,
compiler/run_tests.sh.