Files
sx/examples/errors/1013-errors-value-failable-reject.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

20 lines
649 B
Plaintext

// Value-carrying `catch` rejection (ERR step E2.1b): when the failable LHS
// carries a value, a non-diverging catch handler must produce a value of the
// success type — a value-less (void) body is a type error (otherwise the
// success and error paths couldn't merge to one value). Diverge instead
// (`return` / `raise`) or yield a value. Positives: `examples/229-value-failable-consume.sx`.
#import "modules/std.sx";
E :: error { Bad }
parse :: (n: i32) -> (i32, !E) {
if n < 0 { raise error.Bad; }
return n;
}
main :: () -> i32 {
x := parse(-1) catch (e) { print("oops\n") }; // error: body yields no value
return x;
}