Skip to content

parse: reject repeated declared decimal marks - #2741

Draft
ryanduguid wants to merge 1 commit into
hledgerorg:mainfrom
ryanduguid:fix/validate-declared-decimal-mark
Draft

ryanduguid wants to merge 1 commit into
hledgerorg:mainfrom
ryanduguid:fix/validate-declared-decimal-mark

Conversation

@ryanduguid

Copy link
Copy Markdown

Fixes #1985 and #1904.

With decimal-mark ., hledger currently accepts 10.999.99 AUD as 1099999 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:

  • Warning-free stack build hledger --ghc-options=-Werror --test --no-run-tests passes.
  • All 18 new functional cases pass. Against upstream 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.
  • Full functional suite with the same Bash runner settings as the upstream baseline: 1,994 passes and 265 failures across 2,259 cases. All 265 failing cases also fail on upstream; no existing case changes from passing to failing. These include Windows executable-name, path and encoding mismatches, so this is not a full suite pass on Windows. Linux and macOS have not been tested locally.

@simonmichael simonmichael added the journal The journal file format, and its features. label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

journal The journal file format, and its features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doubled decimal mark typo not detected, even with decimal-mark

2 participants