ERR/E2.4b: failable or chains
`lhs or rhs` with failable operands now lowers as a full short-circuit chain (was a loud bail). Each failing attempt routes to the next operand; the chain resolves when an operand succeeds or a value terminator absorbs; total failure propagates to the function — or, when the chain is the operand of a `catch`, to the handler. All in ir/lower.zig. - Dispatch (lowerBinaryOp .or_op): structural `orIsFailableChain` (an operand is a `try`, error-channel-typed, or a nested failable `or` chain) instead of the type-only `exprIsFailable(lhs)`, which missed nested chains (a try-chain's value type is non-failable T). - inferExprType .or_op: a failable chain reports its success type via `orChainSuccessType` (was `.bool`). - lowerFailableOr rewritten: flatten the left-assoc chain, lower operands left-to-right. Non-final failure → push frame + fall to next operand block (no function exit, so onfail doesn't fire). Success → clear trace + merge. Final failure → push frame + route to a `catch` target (chain_fail_target field) if set, else propagate (cleanup + error return). Value terminator → clear + merge the terminator value. Subsumes the E2.4a path. Widening factored into `checkEscapeWidening`, checked only at a propagating final operand. - Catch-over-chain: lowerCatchOverChain sets chain_fail_target so the chain's total failure reaches the handler (binds the final tag, may inspect the trace, clears on non-diverging exit). Verified JIT + AOT: 2-/3-operand chains, bare chain + value terminator, void chains, all-fail propagation (exit 1 + trace), catch-over-chain, trace clear-on-absorb, onfail gating. examples/246-failable-or-chain.sx (exit 120), 247-failable-or-chain-propagate.sx (exit 1 + trace).
This commit is contained in:
1
tests/expected/246-failable-or-chain.exit
Normal file
1
tests/expected/246-failable-or-chain.exit
Normal file
@@ -0,0 +1 @@
|
||||
120
|
||||
1
tests/expected/246-failable-or-chain.txt
Normal file
1
tests/expected/246-failable-or-chain.txt
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
tests/expected/247-failable-or-chain-propagate.exit
Normal file
1
tests/expected/247-failable-or-chain-propagate.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
8
tests/expected/247-failable-or-chain-propagate.txt
Normal file
8
tests/expected/247-failable-or-chain-propagate.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
error: unhandled error reached main: error.A
|
||||
error return trace (most recent call last):
|
||||
frame 0: <location pending DWARF> (raw 1)
|
||||
frame 1: <location pending DWARF> (raw 1)
|
||||
frame 2: <location pending DWARF> (raw 1)
|
||||
frame 3: <location pending DWARF> (raw 1)
|
||||
frame 4: <location pending DWARF> (raw 1)
|
||||
frame 5: <location pending DWARF> (raw 1)
|
||||
Reference in New Issue
Block a user