ERR/E1.4a: standalone try sema + pure-failable propagation + named widening
`try f()` (standalone form) now propagates a failable callee's error to the enclosing failable function. E1.4 was split: E1.4a = standalone try (failure target = function-propagation); E1.4b = fallback-target routing + failable-`or` + whole-program SCC for inferred sets + empty-inferred warning. - lowerExpr: `.try_expr` -> lowerTry - lowerTry: (1) try legal only inside a failable fn; (2) the sole failable-operand check (errorChannelOf(inferExprType(operand))); (3) named-caller widening (checkErrorSetSubset at the propagation site); (4) pure-failable lowering — condBr on tag != 0: propagate (run defers + ret the widened tag) vs continue on success - inferExprType: `.try_expr` arm (success type: void for pure-failable) - lowerBinaryOp .or_op: bail loudly on a failable LHS (exprIsFailable); the optional-`or` path is unchanged for non-failable LHS - value-carrying callee/caller `try` bail loudly (pending E2's tuple ABI) Tests: examples/221-try.sx (positive propagation, exit 5), examples/222-try-rejections.sx (3 stable rejections: outside-failable, non-failable operand, named-widening miss; exit 1). Gates: zig build, zig build test, 260/260 examples.
This commit is contained in:
1
tests/expected/221-try.exit
Normal file
1
tests/expected/221-try.exit
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
1
tests/expected/221-try.txt
Normal file
1
tests/expected/221-try.txt
Normal file
@@ -0,0 +1 @@
|
||||
try result: 5
|
||||
1
tests/expected/222-try-rejections.exit
Normal file
1
tests/expected/222-try-rejections.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
17
tests/expected/222-try-rejections.txt
Normal file
17
tests/expected/222-try-rejections.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
error: `try` is only valid inside a failable function (a return type with `!` or `!Named`)
|
||||
--> /Users/agra/projects/sx/examples/222-try-rejections.sx:20:5
|
||||
|
|
||||
20 | try ga(); // error: `try` outside a failable function
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `try` requires a failable expression; operand has type 's32'
|
||||
--> /Users/agra/projects/sx/examples/222-try-rejections.sx:26:5
|
||||
|
|
||||
26 | try plain(); // error: operand has type s32 (not failable)
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: error tag 'error.Yb' is not in caller's error set 'A'
|
||||
--> /Users/agra/projects/sx/examples/222-try-rejections.sx:32:5
|
||||
|
|
||||
32 | try gb(); // error: Yb not in caller's error set A
|
||||
| ^^^^^^^^
|
||||
Reference in New Issue
Block a user