ERR/E3.0 (slice 3c): source snippet + caret in traces
Each trace frame now shows the offending source line with a `^` caret under the column — in the catch-handler formatter, the failable-main C reporter, and the comptime path. The source line is embedded at compile time as a 5th Frame field (line_text), not read from disk at runtime: the file field is a basename and a runtime read would add a filesystem dependency that fails under the test harness and on locked-down targets. - errors.lineAt(src, offset): shared helper for the whole source line. - Frame gains line_text (mirrored in emit_llvm getFrameStructType, trace.sx Frame, sx_trace.c SxFrame). emitTraceFrame embeds it; the interp .trace_resolve extracts it from the source map. - trace.sx (new spaces helper) and the C reporter render the line + a col-aligned caret, guarded on a non-empty line_text. Snapshots 243/244/247/253 regenerated. Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
[stdout] caught BadInput
|
||||
error return trace (most recent call last):
|
||||
leaf at 243-trace-format.sx:20:16
|
||||
if n < 0 { raise error.BadInput; } // pushes frame 0
|
||||
^
|
||||
mid at 243-trace-format.sx:25:5
|
||||
try leaf(n); // propagation pushes frame 1
|
||||
^
|
||||
[stdout] recovered; trace buffer now empty (len 0)
|
||||
|
||||
@@ -2,4 +2,8 @@ v = 10
|
||||
error: unhandled error reached main: error.Empty
|
||||
error return trace (most recent call last):
|
||||
inner at 244-failable-main.sx:18:17
|
||||
if n == 0 { raise error.Empty; } // pushes a frame
|
||||
^
|
||||
main at 244-failable-main.sx:26:10
|
||||
w := try inner(0); // raises Empty → propagates to main
|
||||
^
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
error: unhandled error reached main: error.A
|
||||
error return trace (most recent call last):
|
||||
fa at 247-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 247-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
fa at 247-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 247-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
fa at 247-failable-or-chain-propagate.sx:14:17
|
||||
if n == 0 { raise error.A; }
|
||||
^
|
||||
main at 247-failable-or-chain-propagate.sx:19:10
|
||||
v := try fa(0) or try fa(0) or try fa(0); // all fail → propagate to main
|
||||
^
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
comptime caught Bad
|
||||
error return trace (most recent call last):
|
||||
leaf at 253-comptime-trace.sx:15:5
|
||||
raise error.Bad;
|
||||
^
|
||||
mid at 253-comptime-trace.sx:19:5
|
||||
try leaf();
|
||||
^
|
||||
--- build done ---
|
||||
|
||||
Reference in New Issue
Block a user