fix(de-DE,nl-NL): guard scale ceilings in the Germanic pair#358
Merged
Conversation
Both emit "undefined" past their long-scale vocabulary. - de-DE: uniform 10^30 across all three forms (ordinal = cardinal + "ste" suffix; currency builds on cardinal). SCALES indexed [scaleIndex-1] from 'tausend' -> ceiling (SCALES.length+1)*3 = 10^30. - nl-NL: cardinal/currency 10^30, but ordinal 10^21 — its ordinal uses a shorter SCALE_ORDINAL table (hoisted to module scope; ceiling derives from its length and it's no longer rebuilt per call). Entry-point pattern; decimal guarded (both spell the fraction via integerToWords(BigInt(remainder))). Verified per locale (well-formed or RangeError; integer/ordinal/decimal boundaries); full suite green (269). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the German (de-DE) and Dutch (nl-NL) locale converters by adding scale-ceiling guards at the public entry points so inputs beyond each locale’s supported long-scale vocabulary throw a uniform RangeError instead of producing malformed output (e.g., "undefined").
Changes:
- Add
tooLargeError-based magnitude checks totoCardinal,toOrdinal, andtoCurrencyfor de-DE and nl-NL (including decimal significant digits where decimals are spelled via the scale builder). - Derive ceiling thresholds directly from each locale’s scale tables (and for nl-NL, from a hoisted
SCALE_ORDINAL), keeping limits consistent with the vocabulary. - Hoist nl-NL
SCALE_ORDINALto module scope to avoid rebuilding it per call and to support derivingMAX_ORDINAL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/nl-NL.js | Adds derived cardinal/ordinal ceilings (incl. decimal significant digits), hoists SCALE_ORDINAL, and applies tooLargeError guards at entry points. |
| src/de-DE.js | Adds a derived cardinal ceiling (incl. decimal significant digits) and applies tooLargeError guards to cardinal/ordinal/currency entry points. |
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.
Tenth in the fix-then-gate series. German + Dutch.
What fuzzing found
Both emit
"undefined"past their long-scale vocabulary:ste)de-DE is uniform (ordinal/currency build on the cardinal). nl-NL's ordinal caps lower because it uses a shorter
SCALE_ORDINALtable (like pt) — for a number whose lowest non-zero group is a scale group.Fix
Entry-point pattern. Cardinal ceiling derived from
SCALES((length + 1) * 3, indexed fromduizend/tausendat 10³). nl'sSCALE_ORDINALhoisted to module scope so its.lengthderivesMAX_ORDINAL(and it's no longer rebuilt per call). Decimal guarded in both (integer-spelled fractions).Verification
Per locale: well-formed string or
RangeErroracross±10⁴⁰; integer/ordinal/decimal boundaries confirmceil−1ok /ceilthrows (de ord 10³⁰, nl ord 10²¹). Existing fixtures green, lint clean, 269 tests.🤖 Generated with Claude Code