Repository navigation
fix(parser): a push or pop whose line has an error changes no state, and its errors are on its own line - #3034
Merged
Merged
Conversation
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?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…and its errors are on its own line beancount's grammar never reduces a statement whose line fails, and an invalid date fails it too (the lexer raises it), so bean-check 3.2.3 neither pushes nor pops there. The push/pop walk skipped the state change only for an ERROR_TOKEN, so `pushtag #a 2024-02-30` still tagged later transactions and was reported never popped, and `poptag #a 2024-02-30` still popped. push_pop_header_fails, the one rule all four directives now ask, fails a header line on an invalid token, any token the statement does not take (first_header_defect: `poptag #a #b`, `poptag #a 2024-01-01`, `popmeta kk: "v"`) or an invalid date (invalid_value_date). pushmeta_value drops its own copies of the last two checks. A pop error, an unclosed push and a deprecated `|` took the directive node's span, which starts at the blank and comment lines before it. node_content_span, the span from the first content token, is now used for them and by fixup_directive_spans, which computed the same start inline. A key pushed twice and never popped is one UnclosedPushmeta, as beancount reports it. Parse-error parity: 92,606 -> 92,739 inputs match, 0 regressions. A generated differential of 6,827 push/pop sequences (beancount vs before vs after, per-line parse and load errors plus every transaction's tags and metadata): 3,212 error rows and 1,136 tag-state rows gained, 0 regressed. BOM matrix: 7 rows now match, one closer, one relabeled as a listed exception (its rewrite rule held only through the old popmeta error). WASM cache 128 -> 130; loader cache stays 76 (directives move only for a source with a parse error, which it never saves). Closes #2995 Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
force-pushed
the
fix/push-pop-invalid-date
branch
from
November 26, 2026 00:15
440b093 to
0bfed8d
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
pushtag,poptag,pushmetaorpopmetawhose line has an error now pushes or pops nothing, the same as beancount 3.2.3. The tags and metadata on later transactions follow from that. A pop error is now reported on the pop's own line.Why
beancount's grammar never reduces a statement whose line fails. An invalid date also fails the line, because beancount's lexer raises it. The push/pop walk in
convert.rsskipped the state change only when the line had anERROR_TOKEN. As a result:pushtag #a 2024-02-30still tagged later transactions#a, and was reported as never popped.poptag #a 2024-02-30still popped, so the next transaction lost its tag.The pop errors, unclosed pushes and the deprecated
|used the directive node's span. That span starts at the blank and comment lines stored before the node, so the error landed on the comment line.How
push_pop_header_fails: one rule for all four directives. A header line fails when it has any of these:first_header_defect, the rule that reports it (poptag #a #b,poptag #a 2024-01-01,popmeta kk: "v");invalid_value_date).pushmeta_valueno longer keeps its own copies of the last two checks.node_content_span: one canonical helper for a node's span without its leading trivia. It is used forInvalidPoptag/InvalidPopmeta, for the unclosed-push spans and forDeprecatedPipeSymbol.fixup_directive_spansused to compute the same start inline and now calls it too. A probe that adds; zzbefore every column-0 line of the matrix and tracked inputs finds no other error that lands on a comment line.One error per key: a key pushed twice and never popped is one
UnclosedPushmeta, as in beancount (leftover metadata 'v, w').Results (beancount 3.2.3)
P pushtag #a / poptag #a 2024-02-30P pushmeta kk: "v" / popmeta kk: 2024-02-30P pushtag #a 2024-02-30 / poptag #aP pushtag #a 2024-02-30 / T#apushtag #a 2024-02-30 / ; c / poptag #apushmeta kk: "v" $ / ; c / popmeta kk:pushtag #a $ / ; c / poptag #apushmeta k: "v" $ / ; c / popmeta k:Every row also matches at load level (
rledger checkagainstloader.load_string). With a transaction after a failed pop, it keeps#a/kk: "v", as in beancount.kkmetadata across beancount, main and this branch.; cthen; d) isunexpected INDENTin beancount, and rledger reports nothing.Assets:Xrewrite rule held only through the old boguspopmetatakes-no-metadata error. The line's own difference, oneP0026for twox<BOM>yruns after a failed line, also exists on main.CACHE_VERSION128 → 130 (129 is fix(wasm): run Early validation over the stream as written, so an E3002 on a transaction that books is reported #3027's).Tests
crates/rustledger-parser/tests/push_pop_failed_header.rscovers:Each count was checked with beancount 3.2.3, and the green and red converters must agree.
crates/rustledger-loader/tests/push_pop_failed_header_test.rsruns the full pipeline and checks error codes, lines and the booked transactions' tags and metadata.How to test
Closes #2995
🤖 Generated with Claude Code