Repository navigation
fix(parser): report an invalid calendar date in a metadata or custom value - #2851
Merged
Merged
Conversation
…value A date in a value position that is not a real calendar date (`kk: 2024-02-30`, a custom or pushmeta value, a cost date) loaded as no value, or an undated lot, with no error. It is now the same InvalidDateValue (P0015) error a directive's own date gets, from one shared check (`invalid_value_date`) run by the header, metadata-line and posting-line checks, so the green and red paths agree. The directive is kept and a metadata key gets no value, as for `kk: 1/0`. A pushmeta with such a date pushes nothing, as in beancount. Year 0 is refused everywhere, header dates included, as beancount refuses it. Loader cache v55, WASM cache v70. Closes #2811 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 v55 doc entry had its blank `///` separator glued onto the text, so rustdoc ran it into the next paragraph. The CHANGELOG said year 0 is refused everywhere; dates built from FFI input still accept it (#2856). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s-reported # Conflicts: # CHANGELOG.md
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
A date in a value position that is not a real calendar date is reported, as beancount reports it, instead of loading as no value with no error.
invalid_value_dateincst/convert.rs, finds the first such date on a line and reports it with the sameInvalidDateValue(P0015) error and message a directive's own date gets (describe_invalid_date). The header check (custom,pushmeta), the metadata-line check and the posting-line check (cost dates) run it, all from the shared directive loop, so the green and red paths agree. It runs only when the line has no grammar defect, so a split date (2024-02-002, compat(parser): dates with extra digits (02024-01-01, 2024-001-01) are rejected; beancount accepts them #2808) keeps its one error.parse_date_tokenrefuses year 0, as beancount does;describe_invalid_datesaysyear 0 out of range. This applies to header dates too.pushmetawith an invalid date pushes nothing, as in beancount, so itspopmetareports the absent key.kk: 1/0(fix(parser): evaluate arithmetic in custom and pushmeta values #2814). beancount drops the directive.bean-check 3.2.3 vs rledger
kk: 2024-02-30(directive, transaction, posting metadata)day is out of range for monthday 30 out of range for 2024-02kk: 2024-13-01,kk: 2024-00-01month must be in 1..12month 13 out of rangekk: 2024-01-00,kk: 2024-02-0,kk: 2023-02-29day is out of range for monthkk: 0000-01-01,0000-01-01 open ...year 0 is out of rangeyear 0 out of rangecustom "x" 2024-02-30day is out of range for monthpushmeta kk: 2024-02-30...popmeta kk:Attempting to pop absent metadata keyNone, no errorpopmeta{1 USD, 2024-02-30}day is out of range for monthkk: 2024-02-29,{1 USD, 2024-02-29}How to test
cargo test -p rustledger-parser --test invalid_value_dates(9 tests). With the source change reverted, 4 fail (metadata, custom, pushmeta, year 0); the other 5 pin behavior main already has or must keep (key with no value, a split date reported once, valid dates, valid and split cost dates).The parser, loader, CLI, LSP and wasm suites pass with
--all-features, including the stray-character matrix and both strict corpus baselines (STRICT_BASELINE=1, 731 files) with no row moved. Clippy-D warnings, rustdoc and fmt are clean.Loader cache v55, WASM cache v70.
Closes #2811
🤖 Generated with Claude Code