cgen: accept an indexed source in aggregate element assignment

The a[i] = src copy loop enumerated ident/field/deref sources; an
N_INDEX rhs fell to the scalar tail and truncated the element. Route
it through the generic place-address funnel. Both stages.
This commit is contained in:
2026-08-07 23:00:02 +09:00
parent 078708770b
commit 7dc3150b65
3 changed files with 47 additions and 8 deletions

View File

@@ -9591,15 +9591,17 @@ fn cgassign(c: *cgen, n: *syntax.node) void = {
// truncation. Compute &a[i] (dest) and the rhs SOURCE
// address, then word-copy esz bytes: the WRITE-twin of
// the #268 let-init copy loop. Source shapes mirror that
// loop (ident, N_DOT field via dotchainaddr, `*p`
// deref); struct-lit sources divert at the placeslit
// gate above (#20), array-lit dies loud (task #32), and
// loop (ident, N_DOT field via dotchainaddr, N_INDEX via
// cgplaceaddr, `*p` deref); struct-lit sources divert at
// the placeslit gate above (#20), array-lit dies loud
// (task #32), and
// a by-value call result still falls to the scalar tail
// — RAX-only store, task #31-G. esz>8
// non-str/non-slice IS a struct/array/tuple here (the
// tagged element already returned above; floats are ≤8).
let aggsrc: bool = (n.rhs.kind == syntax.nkind.N_IDENT)
|| (n.rhs.kind == syntax.nkind.N_DOT)
|| (n.rhs.kind == syntax.nkind.N_INDEX)
|| (n.rhs.kind == syntax.nkind.N_UN
&& n.rhs.op == syntax.tkind.TK_STAR);
if (esz > 8 && !isstrtype(c, elemtn)
@@ -9663,9 +9665,15 @@ fn cgassign(c: *cgen, n: *syntax.node) void = {
emitsymname(c, n.rhs.str);
emitline("(SB), SI\n");
};
} else {
} else { if (n.rhs.kind == syntax.nkind.N_DOT) {
dotchainaddr(c, n.rhs, "SI");
};};
} else {
if (!cgplaceaddr(c, n.rhs, "SI")) {
let msrc: str = "indexed aggregate assignment source unresolved\n";
os.write(2, msrc.ptr, msrc.len: u64);
os.exit(1);
};
};};};
emitline("\tPOPQ\tBX\n"); // dest
let kc: i32 = 0;
for (kc + 8 <= esz) {