wcc: defer capacity 32 with a loud cap error, both stages

wwstage capped defers at 16 and SILENTLY DROPPED the 17th; cstage
capped at 32. Align the cap at 32 and make exceeding it a loud
compile error in BOTH stages — the silent 16-vs-32 split was the bug
(a defer that never runs is a leaked resource). Both stages move in
one commit: one cap contract.
This commit is contained in:
2026-06-13 04:31:12 +09:00
parent 1f2bc7fc26
commit 92cd573197
7 changed files with 230 additions and 15 deletions

View File

@@ -14725,9 +14725,11 @@ cgstmt(Cg *c, Node *n, Local **locals, int *frame)
break;
}
case N_DEFER:
if (ndefers < DEFER_MAX) {
defers[ndefers++] = n->lhs;
}
/* #40: at the cap, fail loud rather than silently drop the
* deferred call (the ww twin in cgenstmt.ww fatals too). */
if (ndefers >= DEFER_MAX)
fatal("cgen: too many defers in one function");
defers[ndefers++] = n->lhs;
break;
case N_YIELD:
/* Evaluate the value into AX, then jump to the enclosing