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:
@@ -49,10 +49,17 @@ fn cgstmt(c: *cgen, n: *node) void = {
|
||||
if (k == nkind.N_YIELD) { cgyield(c, n); return; };
|
||||
|
||||
if (k == nkind.N_DEFER) {
|
||||
if (c.defertop < DEFER_MAX) {
|
||||
c.deferbuf[c.defertop] = n.lhs;
|
||||
c.defertop += 1;
|
||||
// #40: at the cap, fail loud in BOTH stages rather than
|
||||
// silently drop the deferred call. cstage's DEFER_MAX was 32
|
||||
// and also dropped silently past it; the runtime-correct target
|
||||
// is a hard stop at the shared cap (cgen.c twin fatals too).
|
||||
if (c.defertop >= DEFER_MAX) {
|
||||
let msg: str = "cgen: too many defers in one function\n";
|
||||
os.write(2, msg.ptr, msg.len: u64);
|
||||
os.exit(1);
|
||||
};
|
||||
c.deferbuf[c.defertop] = n.lhs;
|
||||
c.defertop += 1;
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user