Files
sx/examples/errors/1035-errors-comptime-trace.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

34 lines
895 B
Plaintext

// Comptime return-trace resolution (ERR E3.0 slice 3b). A `#run` block that
// raises, propagates via `try`, and catches the error, then formats the trace
// with `trace.print_current()`. At comptime a frame is a packed
// `(func_id, span.start)` (not a `*Frame`); the interpreter's `.trace_resolve`
// unpacks it and resolves `file:line:col` via the module + source map — so the
// comptime trace prints the same `func at file:line:col` form as a runtime one.
// Expected exit: 0 (the error is caught; the trace is printed during the build).
#import "modules/std.sx";
trace :: #import "modules/std/trace.sx";
TErr :: error { Bad };
leaf :: () -> !TErr {
raise error.Bad;
}
mid :: () -> !TErr {
try leaf();
}
probe :: () {
mid() catch (e) {
print("comptime caught {}\n", e);
trace.print_current();
};
}
#run probe();
main :: () -> i32 {
return 0;
}