w6c: tagged GLOBAL reassign emits the store

cstage silently dropped the store on reassigning a module-global
tagged union; mirror the landed wwstage emission (tag+payload to
g(SB) via the widener). Closes the cs half of the F8 #263 pair; the
repro row flips to cs==ww==correct. Task #41.
This commit is contained in:
2026-06-12 22:31:09 +09:00
parent ef7c0c1675
commit 5ff5f4b4fe
2 changed files with 37 additions and 26 deletions

View File

@@ -6909,7 +6909,27 @@ cgexpr(Cg *c, Node *n, Local *locals)
if (!rhs_sret_call) {
int off = localfind(locals,
n->lhs->str);
if (off == 0) break;
if (off == 0) {
/* #41 (#263): a module-global
* tagged ident has no BP slot —
* LEAQ g(SB),BX then store
* tag+payload off BX (mirror the
* global-struct-field tagged arm
* above + the local arm below).
* Pre-fix this break dropped the
* store entirely; ww half landed
* in F8-c5. */
if (let_islet(n->lhs->str)) {
ins2(c, A_LEAQ,
masym(c, n->lhs->str),
areg(D_BX));
cg_widen_tagged_store(c,
&locals, lu, n->rhs,
D_BX, 0,
(int)lu->size);
}
break;
}
cg_widen_tagged_store(c, &locals, lu,
n->rhs, D_BP, off, (int)lu->size);
break;