Repository navigation
fix(parser): report a syntax error at a multi-line string on the line the string ends - #3033
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
… the string ends bison reports a syntax error where its lookahead token ends, so for a string that runs over line ends bean-check 3.2.3 names the string's last line. The parser started such an error at the string, so `rledger check`, the LSP, WASM and the FFI all put it on the string's first line. report_at_multi_line_string_ends, the last error pass, now moves the span's start to the string's last line (the end is kept, the message still names the string), so every surface reports beancount's line from the one span. The offending token is found by grammar_fails_at, the rule report_invalid_dates already used (now shared): an indented line after a gap fails at its indent and stays. A dropped directive's whole-node error uses its header's failure point (`note "a\nb"`). Builder errors stay on the statement's first line: an invalid booking method, and too many strings on a transaction header, whose range now starts at the first string. Related multi-line cases fixed with it: - quiet_after_failed_line_starts: a column-0 failed line holding a multi-line string ends where the string does, so the lines after it are quiet as after any failed line; - report_invalid_dates: a date on a string's last line is on the header's statement line, so `event "a\nb" 2024-02-30` is one error. Parse-error parity: 92,545 -> 92,606 inputs match, 0 regressions. A generated differential of 9,896 multi-line-string inputs: 4,617 gained, 245 closer, 0 regressed, 0 further. BOM matrix unchanged. WASM cache 127 -> 128; the loader cache stays at 76 (parsed directives do not move). Closes #2994 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on a transaction header The error now starts at the first string, on the transaction's first line (#2994), so the two parser-lima files with three header strings hash differently. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/multiline-string-error-line
branch
from
November 25, 2026 23:01
cf6462d to
0be66ab
Compare
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.
What
A syntax error whose offending token is a string that runs over line ends is now reported on the line the string ends, as bean-check 3.2.3 reports it. This holds in
rledger check(text and JSON), the LSP, WASM and the FFI.Why
bison reports a syntax error at the lexer's current line, which is where the lookahead token ends. For a multi-line
STRINGthat is the string's last line. The parser started the error at the token, soLineIndexput it on the string's first line.How
report_at_multi_line_string_endsis a new last error pass inconvert.rs. It moves the error's span start to the first byte of the string's last line and keeps the span's end. Every surface maps that one span, so they all agree, and the message still names the string.grammar_fails_at. This rule used to live inline inreport_invalid_datesand is now factored out and shared by both passes. On an indented line after a gap (a blank line, or the top of the file), beancount fails at the INDENT, so the error stays on the line the string starts.grammar_failures), e.g.note "a\nb".txn_header::TOO_MANY_STRINGS).quiet_after_failed_line_starts: a column-0 failed line that holds a multi-line string now ends where the string does. The lines after it are quiet, as after any other failed line ("a\nb"thenkk: 5).report_invalid_dates: a bad date on a string's last line counts as being on the header's statement line, soevent "a\nb" 2024-02-30is one error.Results (bean-check 3.2.3)
P"a\nb"\nSP"a\nb"\nP"a\nb\nc"\nSPoption "title" "a\nb" "c\nd"\nS"\n", blank line inside) in 77 positions, 4 prefixes (including inside a recovery window) and 6 suffixes. Result: 4,617 gained, 245 closer, 556 sideways, 0 regressed, 0 further.unexpected EOLon the next line (option "a"→ 2, rledger 1). With a multi-line string last, rledger now reports the string's last line, one line before beancount, as on one line.CACHE_VERSION127 → 128. The loader cache stays at 76, because parsed directives do not move.Tests
crates/rustledger-parser/tests/multi_line_string_error_line.rs: the issue rows plus extra cases. They cover every position, the gap and indent cases, builder errors, the invalid date, quiet windows, CRLF, BOM, unclosed strings, the end-of-line difference and the span. Each count was checked with bean-check 3.2.3, and the green and red converters must agree.crates/rustledger-lsp/tests/multi_line_string_error_line.rs: the LSP diagnostic line (UTF-8 and UTF-16) must equal theLineIndexline thatrledger checkprints, and both must equal beancount's.crates/rustledger/tests/multi_line_string_error_line_test.rs:rledger check --format jsonand the text header report lines 4 and 5.How to test
Closes #2994
🤖 Generated with Claude Code