Repository navigation
fix(parser): an orphan indented line reports beancount's indent error and each invalid token on it; pin the tag-line deviation - #3040
Merged
Conversation
robcohen
force-pushed
the
fix/orphan-indent-errors
branch
from
November 26, 2026 04:42
86cb46d to
d1a0b3f
Compare
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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… and each invalid token on it; pin the tag-line deviation beancount's grammar takes an indent only inside a dated entry's body. On an indented line no entry continues (top of file, after a blank or whitespace-only line, a column-0 comment or skipped line, an undated directive, or a statement bison built whole inside a body) bison reports `syntax error, unexpected INDENT` and starts its recovery at that indent: the line then carries that error plus one per lexer error on it (invalid token, invalid date, malformed number). rledger's one line error stood for both, so ` $x` was one error where bean-check 3.2.3 gives two. - The recovery pass adds the missing lexer error on such a line, named like the line's later invalid tokens (`invalid token '$x'`, `invalid number '1,50'`). ` !` stays one error; a BOM keeps its own P0026. - Where bison is still recovering at the indent (within two gap lines of an indented comment rledger accepts on purpose, or after an indented line bison fails at that rledger reads as part of the entry), the line keeps its lexer errors only. - After a stray `\r`, a BOM or an error that started no window, nothing is added (that recovery is not modeled). - Tag line after the first posting: rledger keeps reporting it on the tag line (bean-check uses the header line). Documented at both body checks, pinned by a test, and the parity harness moves beancount's report to the tag line. Parity corpus: 107,279 -> 107,435 matching, 0 regressions (107,280 from the tag normalization alone). BOM matrix unchanged. Generated differentials (1.26M inputs): 51,974 gained, 1,076 closer, 16 moved away. WASM cache 136. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/orphan-indent-errors
branch
from
November 26, 2026 05:16
d1a0b3f to
6ceb680
Compare
robcohen
added a commit
that referenced
this pull request
Nov 26, 2026
…breadth-first order, each currency once (#3038) beancount 3.2.3 parses its files breadth first and `aggregate_options_map` merges `operating_currency` in that order, `uniquify`d (first occurrence wins, the top-level file's own repeats included). rledger merged it depth first and kept repeats: `main` (MMM) including `x` (XXX, including `z` ZZZ) then `y` (YYY) gave [MMM, XXX, ZZZ, YYY] against [MMM, XXX, YYY, ZZZ], and USD in main and an include gave [USD, USD, EUR] against [USD, EUR]. Auditing the other options beancount aggregates across files: `display_precision` is merged into the top-level file's display context with `DisplayContext::update_from`, which keeps a fixed precision, so the top-level file's value wins; rledger let the last file read win (an include's USD:0.001 rendered 1.23456 USD as 1.235 where bean-query gives 1.23). `insert_pythonpath` becomes a sorted set there (no order) and has no effect in rledger. Included plugins are ignored by beancount and run by rledger deliberately; their order is unchanged. - `Options::set_in_file_at` records each merged option's values with its file; `Options::merge_across_files(ranks)` is the one merge, called by `Loader::load` over `SourceMap::parse_ranks` before the display context and the cache see the options. Every surface (CLI, LSP, WASM, FFI) reads the loader's options or the cache's merged copy. - `apply` lists a repeated operating currency once, for options set without the loader. - Loader CACHE_VERSION 77 -> 78 (cached values change), WASM pin 78, WASM CACHE_VERSION 137 (135, 136 taken by #3039, #3040). - Tests: unit tests for the merge; loader tests for the issue's trees, a duplicate include, a disk glob and a cache round trip, all checked against bean-check 3.2.3; drift guards across the loader, WASM `Ledger` (and restored), ffi-wasi, the LSP, and the CLI cold and on a cache hit (`report returns` currency, `query` precision). Closes #3038 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 26, 2026
…breadth-first order, each currency once (#3041) * fix(loader): merge operating_currency across includes in beancount's breadth-first order, each currency once (#3038) beancount 3.2.3 parses its files breadth first and `aggregate_options_map` merges `operating_currency` in that order, `uniquify`d (first occurrence wins, the top-level file's own repeats included). rledger merged it depth first and kept repeats: `main` (MMM) including `x` (XXX, including `z` ZZZ) then `y` (YYY) gave [MMM, XXX, ZZZ, YYY] against [MMM, XXX, YYY, ZZZ], and USD in main and an include gave [USD, USD, EUR] against [USD, EUR]. Auditing the other options beancount aggregates across files: `display_precision` is merged into the top-level file's display context with `DisplayContext::update_from`, which keeps a fixed precision, so the top-level file's value wins; rledger let the last file read win (an include's USD:0.001 rendered 1.23456 USD as 1.235 where bean-query gives 1.23). `insert_pythonpath` becomes a sorted set there (no order) and has no effect in rledger. Included plugins are ignored by beancount and run by rledger deliberately; their order is unchanged. - `Options::set_in_file_at` records each merged option's values with its file; `Options::merge_across_files(ranks)` is the one merge, called by `Loader::load` over `SourceMap::parse_ranks` before the display context and the cache see the options. Every surface (CLI, LSP, WASM, FFI) reads the loader's options or the cache's merged copy. - `apply` lists a repeated operating currency once, for options set without the loader. - Loader CACHE_VERSION 77 -> 78 (cached values change), WASM pin 78, WASM CACHE_VERSION 137 (135, 136 taken by #3039, #3040). - Tests: unit tests for the merge; loader tests for the issue's trees, a duplicate include, a disk glob and a cache round trip, all checked against bean-check 3.2.3; drift guards across the loader, WASM `Ledger` (and restored), ffi-wasi, the LSP, and the CLI cold and on a cache hit (`report returns` currency, `query` precision). Closes #3038 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(loader): don't link the private MERGED_ACROSS_FILES from public docs Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 26, 2026
…re recovery shapes count as bean-check does The shapes #3040 left in cst/recovery.rs's model of bison's error recovery. - An invalid account (P0006, rledger's line error for an unreadable line that holds an account like `Assets:Café` or `Assets:<BOM>A`) started no recovery window, so the lines bison keeps quiet after it kept their errors. beancount's lexer reads such an account into an ACCOUNT (or, glued to more, an invalid token) and its grammar fails on the line as on any other: the error now starts the window like rledger's other line errors. Not on a line holding a stray `\r` (unmodeled, as before). - An undated declaration bison's recovery starts mid-line and that fails past its first three tokens (`popmeta pushmeta kk: @`) builds nothing: bison reports that failure and restarts its recovery there. The failure is now reported (an error is added where rledger has none) and the window goes on from it. - An indented line after an `option` bison builds inside a transaction's body fails at its indent; on ` $x` the indent's error is added beside the invalid token's, which rledger names already. - A line's grammar failure counts as one error beside its invalid tokens where it is known to be bison's own (a column-0 statement failing among its first three tokens, a body line failing at its first token, nothing before keeping bison recovering), so a misgrouped number there is reported. An indented line whose date starts no statement (` date: 2024-01-02`) no longer ends the read-back recovery. Parity corpus: 107,435 -> 107,631 matching, 0 regressions. BOM matrix: 52 more rows match, none fewer. Generated differentials (1.26M inputs, main vs branch): 8,105 gained, 473 closer, 48 moved away (44 with a stray `\r`, a BOM or control characters). WASM cache 139. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 26, 2026
…re recovery shapes count as bean-check does The shapes #3040 left in cst/recovery.rs's model of bison's error recovery. - An invalid account (P0006, rledger's line error for an unreadable line that holds an account like `Assets:Café` or `Assets:<BOM>A`) started no recovery window, so the lines bison keeps quiet after it kept their errors. beancount's lexer reads such an account into an ACCOUNT (or, glued to more, an invalid token) and its grammar fails on the line as on any other: the error now starts the window like rledger's other line errors. Not on a line holding a stray `\r` (unmodeled, as before). - An undated declaration bison's recovery starts mid-line and that fails past its first three tokens (`popmeta pushmeta kk: @`) builds nothing: bison reports that failure and restarts its recovery there. The failure is now reported (an error is added where rledger has none) and the window goes on from it. - An indented line after an `option` bison builds inside a transaction's body fails at its indent; on ` $x` the indent's error is added beside the invalid token's, which rledger names already. - A line's grammar failure counts as one error beside its invalid tokens where it is known to be bison's own (a column-0 statement failing among its first three tokens, a body line failing at its first token, nothing before keeping bison recovering), so a misgrouped number there is reported. An indented line whose date starts no statement (` date: 2024-01-02`) no longer ends the read-back recovery. Parity corpus: 107,435 -> 107,631 matching, 0 regressions. BOM matrix: 52 more rows match, none fewer. Generated differentials (1.26M inputs, main vs branch): 8,105 gained, 473 closer, 48 moved away (44 with a stray `\r`, a BOM or control characters). WASM cache 139. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Nov 26, 2026
…re recovery shapes count as bean-check does (#3043) The shapes #3040 left in cst/recovery.rs's model of bison's error recovery. - An invalid account (P0006, rledger's line error for an unreadable line that holds an account like `Assets:Café` or `Assets:<BOM>A`) started no recovery window, so the lines bison keeps quiet after it kept their errors. beancount's lexer reads such an account into an ACCOUNT (or, glued to more, an invalid token) and its grammar fails on the line as on any other: the error now starts the window like rledger's other line errors. Not on a line holding a stray `\r` (unmodeled, as before). - An undated declaration bison's recovery starts mid-line and that fails past its first three tokens (`popmeta pushmeta kk: @`) builds nothing: bison reports that failure and restarts its recovery there. The failure is now reported (an error is added where rledger has none) and the window goes on from it. - An indented line after an `option` bison builds inside a transaction's body fails at its indent; on ` $x` the indent's error is added beside the invalid token's, which rledger names already. - A line's grammar failure counts as one error beside its invalid tokens where it is known to be bison's own (a column-0 statement failing among its first three tokens, a body line failing at its first token, nothing before keeping bison recovering), so a misgrouped number there is reported. An indented line whose date starts no statement (` date: 2024-01-02`) no longer ends the read-back recovery. Parity corpus: 107,435 -> 107,631 matching, 0 regressions. BOM matrix: 52 more rows match, none fewer. Generated differentials (1.26M inputs, main vs branch): 8,105 gained, 473 closer, 48 moved away (44 with a stray `\r`, a BOM or control characters). WASM cache 139. Co-authored-by: Claude Opus 5.5 <[email protected]>
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 changed
Orphan indented lines (the general shape #3036 left). beancount's grammar takes an indent only inside a dated entry's body. On an indented line that no entry continues, bison reports
syntax error, unexpected INDENTand starts its recovery at the indent. That happens at the top of the file, after a blank or whitespace-only line, after a column-0 comment or a line its lexer skips, after an undated directive (option,pushtag, ...), or after a statement bison built whole inside a body. The rest of the line is then quiet except for its lexer's errors, so beancount reports 1 + (invalid tokens, invalid dates and malformed numbers on the line) there. rledger's single line error covered both the indent and the line's first invalid token, so$x,"abc,1,50andAssets:A 1,50 USDeach got one error where bean-check 3.2.3 gives two.cst/recovery.rsnow adds the missing lexer error on those lines, named the same way as the line's later invalid tokens (unexpected input: invalid token '$x',invalid number '1,50'), so the second error tells you which token is wrong.!has no invalid token, so it stays one error. A BOM already has its ownP0026, which names it.; cthen$xis one error; with two blank lines between, it is two);option "a" "b"in a transaction).\r, a BOM, or an error that started no recovery window (an invalid account), because that recovery is not modeled.test_quiet_bison_recovery_scans_linear_bytesgains three shapes for this.Tag line after the first posting (deliberate deviation, #2575). rledger keeps reporting this error on the tag line, where the mistake is. bean-check reports
Tags or links not allowed after first Postingon the transaction's header line. This PR:test_parse_tags_after_first_posting_are_reported_on_the_tag_line;scripts/compat-parse-error-parity.pymove beancount's report to the k-th late tag line of its transaction, with a self-test for it.The indented-comment deviation (
test_parse_indented_comment_after_a_column_0_comment_is_accepted) is unchanged.Measurements (bean-check 3.2.3)
--update.STRICT_BASELINE=1parser-corpus and cst-corpus manifests: pass, no drift.\r, a BOM, control characters, or a line beancount fails at that rledger does not report.WASM
CACHE_VERSION136 (134 is #3037, merged; 135 is held by #3039). Rebased onto #3037; loader cache v77.How to test
Clippy (
-D warnings) and the parser, loader, wasm, lsp and rustledger test suites pass locally.🤖 Generated with Claude Code