Files
sx/examples/1052-errors-cleanup-transitive-reject.sx
agra 95895a3bb2 test(ir): lock error-flow diagnostics before A5.2 extraction (A5.2 scaffolding step 1)
Test-first scaffolding for the path-sensitive error-flow pass
(checkErrorFlow/analyzeFnBody/flowWalk/flowIf/checkCleanupBody) before it
moves into src/ir/error_flow.zig. No compiler change — both examples lock
current behavior.

- 1051-errors-cleanup-closure-boundary (accepted): a closure literal inside a
  `defer` body is its own function boundary — the E1.7 cleanup rule and the
  parser's try/raise ban both stop at the lambda, and E1.8 value-slot liveness
  runs per-boundary. Pins checkCleanupNode's `.lambda` stop + flowExpr's
  `.lambda` recursion. Constructible since issue 0073 (0310).
- 1052-errors-cleanup-transitive-reject (exit 1): the E1.7 cleanup check is
  transitive — bare failables nested in an `if` (both branches), a nested
  block, and a `while` body all reject. Pins checkCleanupNode's recursive arms,
  distinct from 1049's direct-body case.

No .test.zig/.ir: diagnostic-pass altitude (checkErrorFlow/A2.4 precedent) —
the pass returns no fact object and emits no IR.

Gate: zig build, zig build test, run_examples.sh -> 360/0.
2026-06-03 06:31:18 +03:00

37 lines
1.1 KiB
Plaintext

// The cleanup-absorption check (ERR step E1.7) is TRANSITIVE: a bare,
// un-absorbed failable call is rejected no matter how deeply it is nested
// inside a `defer` / `onfail` body's control flow — through `if` (both
// branches), nested blocks, and loops. 1049 covers the direct-body case; this
// pins the recursive arms of `checkCleanupNode` (`.if_expr`, `.block`,
// `.while_expr`) before A5.2 extracts the pass into its own module.
//
// Three bare failables, three rejections; the program never runs (exit 1).
#import "modules/std.sx";
E :: error { Bad }
failing :: () -> !E { raise error.Bad; }
work :: (n: s32) -> !E {
defer {
if n > 0 {
failing(); // REJECTED: nested in the `if` then-branch
} else {
{ failing(); } // REJECTED: nested block in the else-branch
}
}
onfail {
while n > 0 {
failing(); // REJECTED: nested in the `while` body
}
}
if n < 0 { raise error.Bad; }
return;
}
main :: () -> s32 {
a := work(-1);
return 0;
}