parse: reject repeated declared decimal marks - #2741
Closed
ryanduguid wants to merge 1 commit into
Closed
ryanduguid wants to merge 1 commit into
ryanduguid wants to merge 1 commit into
Conversation
Author
|
Closing along with #2740, since both were made with AI tools and don't meet https://hledger.org/AI.html. |
simonmichael
added a commit
that referenced
this pull request
Sep 25, 2026
…tly (#1985, #1904) With a decimal-mark directive or decimal-mark CSV rule in effect, a number in that file that is clearly using a different decimal mark (like 1,000.00 when decimal-mark , is declared) is now reported as an error rather than being accepted. So is a number using the declared decimal mark more than once (like 1.2.34 or 10.999.99 when decimal-mark . is declared - previously this was silently read as 1234 or 1099999). This applies to all amounts, including costs, balance assertions, and CSV fields and rule-generated amounts. The commodity and D directives may use a different decimal mark from the one declared by decimal-mark, since they are only declaring display style in that case. (And if decimal-mark is not declared, they influence parsing as in hledger 1 - their decimal marks help interpret ambiguous numbers like 1,000, but are not enforced otherwise. So if you want the stricter checking, declare decimal-mark.) It means that some existing journal files or CSV rules files with a decimal-mark declaration, and mixed decimal marks in their data, will now be rejected. To resolve, fix the mixed decimal marks. Also, errors within a cost amount (after @ or @@) are now reported specifically, instead of as a generic parse error at the @. See also: prior work at #2741 AI usage: Claude Opus 5.5, ~83k output tokens
Member
|
Thank you @ryanduguid. I followed up with ac17d01 to fix the issue. |
ryanduguid
added a commit
to ryanduguid/ryanduguid
that referenced
this pull request
Sep 27, 2026
## Summary The hledger fork is archived (27 September 2026) because upstream closed hledgerorg/hledger#2740 and hledgerorg/hledger#2741 and no pull request by me is open there. FORKS.md now says so under "Forks with no open contribution". ## Evidence - **Before:** `archived=false`; FORKS.md listed hledger only as due for review. **After:** `gh api repos/ryanduguid/hledger` reports `archived=true`; FORKS.md records the archive. ## Merge danger **Door:** two-way. **Blast radius:** docs ## Unverified None.
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.
Fixes #1985 and #1904.
With
decimal-mark ., hledger currently accepts10.999.99 AUDas1099999 AUD. Repeated periods are classified as digit group separators before the declared format is considered. This affects journal amounts, balance assignments and CSV imports.Pass the declared amount style to the shared number conversion. When a number has no explicit decimal part, reject grouping that uses the declared decimal mark. This applies the same validation to journal and CSV parsing, including commodity/default formats. Unambiguous formats and inference without a declaration keep their existing behaviour, so commodity display formats can still differ from the parsing format.
Add parser tests and 18 functional cases covering amounts, balance assertions and assignments, transaction prices, declaration precedence, commodity display formats, CSV fields and rule-generated amounts.
Validation on Windows with GHC 9.14.1:
stack build hledger --ghc-options=-Werror --test --no-run-testspasses.f6f7661d, the same file has 11 failures and seven passes.just unittest: all 252 tests pass.just doctest: all 303 examples pass.just embedtest: passed.