parse: reject repeated declared decimal marks - #2741
Draft
ryanduguid wants to merge 1 commit into
Draft
ryanduguid wants to merge 1 commit into
ryanduguid wants to merge 1 commit into
Conversation
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.