Skip to content

An error shows the entry it came from, with carets; a golden program - #243

Merged
jonruttan merged 2 commits into
mainfrom
feat/error-carets
Nov 20, 2026
Merged

jonruttan merged 2 commits into
mainfrom
feat/error-carets

Conversation

@jonruttan

Copy link
Copy Markdown
Owner

Two commits.

An error shows where it came from

An error at the prompt printed its own line and nothing about where it was. Both loops now print the layout of a CPython traceback's last frame ahead of it:

>>> q = [1, 2][7]
  File "<stdin>", line 1
    q = [1, 2][7]
    ^^^^^^^^^^^^^
Error: index: list index out of range
  • The location is the entry. A token carries no position and an emitted form no line, so a one-line entry is marked and a block is shown by its header with no carets.
  • A program on standard input is reported by its own line number. An entry typed at the editor is line 1.
  • The Error: line is unchanged.
  • The two loops share one entry runner, %py-entry-run.

Spec: 91-repl-editor, four new cases and one updated.

A golden program

tests/golden/shapes.py is a fixed program with one of each layout the tokenizer and the parser decide. D0-golden holds its token stream and the forms the parser emits, one a line, so a change in the engine's reader, a dialect or the parser shows as the lines it moved. A second parse in the same process is held to the same forms.

Verification

  • 91-repl-editor (18 cases) and D0-golden (3 cases) pass on x-lang v0.58.0.
  • The branch was cut before main moved to its current release requirement; the full suite was not run locally.

🤖 Generated with Claude Code

jonruttan and others added 2 commits November 20, 2026 00:21
tests/golden/shapes.py is a fixed program with one of each layout the
tokenizer and the parser decide.  D0-golden holds its token stream and the
forms the parser emits, one a line, so a change in the engine's reader, a
dialect or the parser shows as the lines it moved.  A second parse in the
same process is held to the same forms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An error at the prompt printed its own line and nothing about where it
was.  Both loops now print the layout of a CPython traceback's last
frame ahead of it: the line the entry began on, its text, and a caret
under each character.  The entry is what is known -- a token carries no
position and an emitted form no line -- so a one-line entry is marked
and a block is shown by its header with no carets.  A program on
standard input is reported by its own line number; an entry typed at
the editor is line 1.  The two loops share one entry runner.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jonruttan
jonruttan merged commit 64433a7 into main Nov 20, 2026
12 checks passed
@jonruttan
jonruttan deleted the feat/error-carets branch November 20, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant