test(ir): pin both lambda arms of the error-flow pass (A5.2 scaffolding review fix)
Codex review of 95895a3 found 1051 reached neither lambda arm it claimed to
pin: the lambda arrived only as a var_decl initializer, which routes through
checkCleanupNode's `.var_decl` arm -> cleanupReject(lambda) -> early-return
(a lambda literal is not failable), so the `.lambda` stop never ran; and its
accepted-direction `if !err` guard would still pass with flowExpr's lambda
recursion removed.
Scaffolding-only fix (no compiler change):
- 1051: add a bare lambda STATEMENT `() -> !E { failing(); };` in the cleanup
body so checkCleanupNode sees a `.lambda` node directly and stops (the bare
failable inside is accepted; were the arm to recurse it would reject like
1052). Output byte-identical — only the .sx gained the statement.
- 1053-errors-nested-lambda-liveness-reject (exit 1): an E1.8 value-slot read
inside a never-called nested lambda, rejected only because flowExpr recurses
via `.lambda => analyzeFnBody`. Remove that arm and the diagnostic vanishes
-> suite fails. This is the discriminating negative 1051 lacked.
Gate: zig build test, bash tests/run_examples.sh -> 361/0.
This commit is contained in:
31
examples/1053-errors-nested-lambda-liveness-reject.sx
Normal file
31
examples/1053-errors-nested-lambda-liveness-reject.sx
Normal file
@@ -0,0 +1,31 @@
|
||||
// Value-slot liveness (ERR step E1.8) is analysed inside a nested lambda as its
|
||||
// OWN boundary: `flowExpr` recurses into a lambda literal via `analyzeFnBody`.
|
||||
// Reading a failable's value slot inside the lambda where its error is NOT
|
||||
// proven absent is rejected — even though the lambda is never called and the
|
||||
// outer function proves nothing for it.
|
||||
//
|
||||
// Negative counterpart to 1051(b): were `flowExpr`'s `.lambda` recursion
|
||||
// removed, the lambda body would go un-analysed and this read would slip
|
||||
// through. The program never runs (exit 1).
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
E :: error { Bad }
|
||||
|
||||
parse :: (n: s32) -> (s32, !E) {
|
||||
if n < 0 { raise error.Bad; }
|
||||
return n * 10;
|
||||
}
|
||||
|
||||
build :: () {
|
||||
emit := () -> s32 {
|
||||
v, err := parse(5);
|
||||
return v; // REJECTED: err not proven absent (inside lambda)
|
||||
};
|
||||
print("unreached\n");
|
||||
}
|
||||
|
||||
main :: () -> s32 {
|
||||
build();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user