Repository navigation
fix(parser): refuse a tag or link line after a transaction's first posting - #2618
Merged
Merged
Conversation
…sting
Beancount's builder refuses a tags-and-links line that comes after a
transaction's first posting ("Tags or links not allowed after first
Posting") and keeps the transaction without those tags. rledger added
them to the transaction silently, so a file bean-check rejects loaded
clean with a tag beancount never attaches.
Such a line is now a parse error at the line, and its tags are not
kept; a tags line before the first posting still joins the
transaction. One rule and one error constructor serve both the red and
green conversions and body checks. Loader and WASM CACHE_VERSION 39.
Closes #2575
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
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 |
The two corpus files with a tag line after a transaction's first posting (the lima fixture and parser-lima/examples_data_full) now parse with an error and without those tags (#2575). Only their parser-output hashes move; source hashes are unchanged. Refs #2575 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Member
Author
Review log
Beancount 3.2.3 ( exit 1. The transaction is kept, with tags |
# Conflicts: # CHANGELOG.md # crates/rustledger-wasm/src/cache.rs
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 beancount does
Beancount 3.2.3, checked with the oracle on the corpus file and on variants:
posting_or_kv_listincludestags_links), but the builder (grammar.py,Builder.transaction) refuses one that comes after the first posting:ParserError("Tags or links not allowed after first Posting: TagsLinks(...)"), one per such line, at any indent.bean-checkexits 1.So the grammar's intent is that tags/links lines continue the header, and only before the postings start.
parser-lima/test-cases_Transactions.TagsAfterFirstPostingis such a file, and lima's own fixture records it as an anomaly.What was wrong
rledger added the late tags to the transaction with no error. A file
bean-checkrejects loaded clean, andSELECT tagsreported a tag beancount never attaches.What changed
Beancount's behavior, which is also the correct reading of the grammar: such a line is a parse error at the line itself (naming its tags), and the transaction is kept without them.
body_tag_joins_transaction(posting_seen), and one error constructor,tags_after_posting_error(convert.rs).convert_transactionand greenconvert_transaction_headerskip body TAG/LINK tokens after the first POSTING node. Both body checks report the line: redtransaction_body_checkand greentl_transaction_body_check, at a newline and at EOF. A line that also has junk on it still gets "unexpected input" instead, as before.CACHE_VERSION39 and WASMCACHE_VERSION39 (+LOADER_CACHE_VERSION_PIN, and the two tripwire fixture versions). A cached parse of such a file holds the late tags and no error.fixture_tests.rs.tests/baselines/parser-corpus.manifest: the parser-output hashes of the two corpus files above move (source hashes unchanged), checked withSTRICT_BASELINE=1over the full corpus.How tested
tags_after_first_posting_are_an_error_and_dropped(parser integration): on bothparseandparse_red_only, a pre-posting tag joins and a post-posting tag and link (indented, and at EOF without a newline) are dropped. Exactly one error per late line, with its tags in the message and its span on that line. The transaction and its postings are kept.parse_green_eq_red_corpusgained four inputs (late tag line, indented + EOF, no trailing newline, junk on the line).green_txn_header_matches_redgained a pre/post mix.convert.rs/green.rsreverted to main (tests kept), the integration test and the updated F2-bis test fail. (The lima allowlist entry is one-sided, asfixture_tests.rsdocuments, so it permits the error rather than requiring it; the integration test is what pins it.)parser-lima/examples_data_full.beancount.bean-checkrejects both too (the latter also for unrelated syntax errors).cargo test --all-featuresfor rustledger-parser, -loader, -wasm, rustledger; clippy workspace-D warningsand the release-feature clippy;cargo doc -D warnings.Closes #2575
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr