You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Errors now show the source position of every call site in the trace:
Error: inner exploded with x=42
at inner (6:12)
at middle (10:12)
at outer (13:1)
Previously: just function names. The (line:col) suffix reveals which
specific call dispatched into each frame — what most languages give
you and what was the next debugging bottleneck after stack traces
themselves landed in Phase 3.
Architecture: position info is attached only to Expression::Call (one
new field, `pos: Pos`). Other expressions inherit their frame's call
site for error context — same coverage every mainstream interpreter
provides at this level. Pos moved from parser.rs to ast.rs and
re-exported, so AST nodes can carry positions without depending on
parser internals.
Tree-walk path: invoke_user_function gained an _at variant that takes
the call site; call_function_at threads pos from Expression::Call
through dispatch. The frame stack is now Vec<(String, Pos)>.
VM path: CompiledFunction carries a parallel Vec<Pos> of op_positions
(same length as ops, padded with Pos::unknown). Op layout is
unchanged — keeps the optimizer / inline-cache / disasm machinery
intact. The compiler's emit_at(op, pos) records the position on
emission. Op::Call dispatch consults op_positions[ip-1] and stashes
it on the Vm via a `next_call_site` side-channel; run_function reads
it on entry, immediately resets so child frames don't inherit.
Synthesized calls (heal-pass safe_divide rewrites, parser-generated
arr_new in the `[N]name` shorthand, the special-cased res()/fold()
keyword forms) carry Pos::unknown() and render with no suffix —
keeps trace lines clean when the call wasn't user-written.
42/42 functional examples produce identical output under tree-walk
and VM. 92/92 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments