Repository navigation
Include column in parse error messages - #73
Merged
Merged
Conversation
Parse errors were formatted as file:line only, while type and safety errors went through format_error and included the column. Use the shared helper so every error reported via the CLI and lyte_compiler_get_error has the file:line:col form the C header documents. Also locate the Endl token at the newline it terminates rather than the start of the following line, so errors such as "expected Rparen, got Endl" point at the end of the offending line instead of the next one. The line counter now advances when the token after the newline is lexed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
It printed a quoted copy of the error to stdout before the real diagnostic was recorded. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2 tasks done
wtholliday
added a commit
that referenced
this pull request
Oct 14, 2026
* Test token locations and fix stale lexer doc comment The comment on Lexer::loc said the column was computed on demand, but it has been set eagerly for every token. Add a unit test pinning the Endl location and the deferred line advance introduced in #73. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Count raw newlines inside string literals The lexer only advanced the line counter for whitespace and comment newlines, so every token after a multi-line string literal reported the wrong line and a column measured from an earlier line. Replace the "previous token was Endl" check with a pending_lines counter that both the newline handler and the string scanner bump. The line advances when the next token is lexed, so the string token keeps the line of its opening quote. The parser's struct-literal backtrack now saves and restores the counter along with the rest of the lexer state. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
file:line: messageincompiler.rs, while type and safety errors went throughformat_errorand included the column. Parse errors now use the shared helper, so every message surfaced by the CLI andlyte_compiler_get_errorhas thefile:line:colform documented inlyte.h.Endltoken is now located at the newline it terminates. Previously the line counter was bumped as soon as the newline was consumed, so an error likeexpected Rparen, got Endlpointed at the next line, column 1. The line advances when the token after the newline is lexed. The parser's one backtracking site saves and restores full lexer state, so it is unaffected.println!inexpect_idthat echoed a quoted copy of the error to stdout.partial_function.lytemoved from line 6 to5:5, which is where the unclosedfoo(actually is.Before:
After:
Test plan
cargo test --workspacepasses (unit tests plus all four golden runners)🤖 Generated with Claude Code