ERR/E1.3: raise sema + pure-failable lowering

`raise EXPR` now terminates a failable function via the error channel.
Scope (Option 2): full raise sema checks + lowering for the pure-failable
shape (`-> !` / `-> !Named`); the value-carrying `-> (T..., !)` shape bails
loudly, deferred to E2's error-channel tuple ABI.

- lowerStmt + tryLowerAsExpr: `.raise_stmt` -> lowerRaise (also routes a
  raise that is a block's last statement, which previously hit unknown_expr)
- lowerRaise: failable-context check (effectiveReturnType + errorChannelOf);
  literal membership via lowerErrorTagLiteral; variable form subset-checked
  via checkErrorSetSubset; pure-failable emits ret(tag)
- lowerErrorTagLiteral skips membership for the bare-`!` inferred placeholder
- plain `return;` in a pure-failable fn emits ret(0) (success / no error)
- parser: in_defer_body flag rejects `raise` inside a `defer` body

Tests: examples/219-raise.sx (positive, exit 8),
examples/220-raise-rejections.sx (3 sema rejections, exit 1), inline parser
test for raise-in-defer. Gates: zig build, zig build test, 258/258 examples.
This commit is contained in:
agra
2026-05-31 19:09:32 +03:00
parent 5a24a1177d
commit 9984fa6b96
8 changed files with 241 additions and 11 deletions

View File

@@ -0,0 +1 @@
8

View File

@@ -0,0 +1 @@
raise result: 8

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,17 @@
error: error tag 'error.NotInSet' is not in error set 'ParseErr'
--> /Users/agra/projects/sx/examples/220-raise-rejections.sx:17:11
|
17 | raise error.NotInSet; // error: NotInSet not in ParseErr
| ^^^^^^^^^^^^^^
error: error tag 'error.Weird' is not in caller's error set 'ParseErr'
--> /Users/agra/projects/sx/examples/220-raise-rejections.sx:24:5
|
24 | raise e; // error: OtherErr not subset of ParseErr
| ^^^^^^^^
error: `raise` is only valid inside a failable function (a return type with `!` or `!Named`)
--> /Users/agra/projects/sx/examples/220-raise-rejections.sx:30:5
|
30 | raise error.BadDigit; // error: main (-> s32) is not failable
| ^^^^^^^^^^^^^^^^^^^^^