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.
This commit is contained in:
32
examples/errors/1003-errors-raise-rejections.sx
Normal file
32
examples/errors/1003-errors-raise-rejections.sx
Normal file
@@ -0,0 +1,32 @@
|
||||
// `raise` rejections (ERR step E1.3):
|
||||
// - `raise` is only valid inside a failable function,
|
||||
// - a literal `raise error.X` must name a tag in the function's set,
|
||||
// - a variable `raise e` must carry a set that is a subset of the
|
||||
// function's set.
|
||||
// The positive case lives in `examples/219-raise.sx`. Parse-time rejections
|
||||
// (`raise` in expression position / inside `defer` / `onfail`) are covered by
|
||||
// the inline parser tests.
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
ParseErr :: error { BadDigit, Overflow }
|
||||
OtherErr :: error { Weird }
|
||||
|
||||
// Literal tag not in the declared set.
|
||||
bad_tag :: () -> !ParseErr {
|
||||
raise error.NotInSet; // error: NotInSet not in ParseErr
|
||||
}
|
||||
|
||||
// Variable whose error set is not a subset of the function's set.
|
||||
makes_other :: () -> !OtherErr { return; }
|
||||
relay :: () -> !ParseErr {
|
||||
e := makes_other(); // e : OtherErr
|
||||
raise e; // error: OtherErr not subset of ParseErr
|
||||
}
|
||||
|
||||
main :: () -> i32 {
|
||||
x := bad_tag(); // force bad_tag to lower
|
||||
y := relay(); // force relay to lower
|
||||
raise error.BadDigit; // error: main (-> i32) is not failable
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user