Skip to content

fix(he): guard scale ceilings in he-IL, hbo-IL#356

Merged
TylerVigario merged 1 commit into
mainfrom
fix/he-family-scale-ceilings
Jun 4, 2026
Merged

fix(he): guard scale ceilings in he-IL, hbo-IL#356
TylerVigario merged 1 commit into
mainfrom
fix/he-family-scale-ceilings

Conversation

@TylerVigario
Copy link
Copy Markdown
Collaborator

Eighth in the fix-then-gate series. Modern + Biblical Hebrew.

What fuzzing found

Both emit "undefined" past their scale vocabulary, with per-form ceilings:

form ceiling cause
cardinal / currency 10²¹ SCALE reaches 10¹⁸ (7 entries)
ordinal 10⁹ past 10⁶ the millions multiplier uses buildScaleSegment (0–999) → "undefined מיליונים" at 10⁹, same shape as the Spanish ordinal

Fix

Entry-point pattern: MAX_CARDINAL (derived from SCALE.length) + MAX_ORDINAL (10⁹) up front, short-circuit in toCardinal/toOrdinal/toCurrency after parsing. No decimal guard — Hebrew reads the fraction digit-by-digit (a 40-digit decimal still converts). hbo-IL (Biblical Hebrew) shares he-IL's structure — and is also the corpus's one valid-BCP-47-but-not-in-CLDR tag.

Verification

Per variant: well-formed string or RangeError across ±10³⁰; integer/ordinal boundary (10²¹/10⁹); long decimals confirmed still clean. Existing fixtures green, lint clean, 269 tests.

🤖 Generated with Claude Code

Both emit "undefined" past their scale vocabulary. Per-form ceilings
differ:

- Cardinal/currency: SCALE reaches 10^18, so ceiling 10^21 (derived from
  SCALE.length).
- Ordinal: past 10^6 the millions multiplier is built with
  buildScaleSegment (0-999), so it overflows to "undefined מיליונים" at
  10^9 (same shape as the Spanish ordinal). Guard at 10^9.

Entry-point pattern: MAX_CARDINAL/MAX_ORDINAL up front, short-circuit in
toCardinal/toOrdinal/toCurrency after parsing. NO decimal guard — Hebrew
reads the fraction digit-by-digit (40-digit decimal still converts).
hbo-IL (Biblical Hebrew) shares he-IL's structure.

Verified per variant (well-formed or RangeError; integer/ordinal
boundary; decimals stay clean); full suite green (269).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 4, 2026 13:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit scale-ceiling guards for Modern Hebrew (he-IL) and Biblical Hebrew (hbo-IL) so inputs beyond each locale’s expressible magnitude throw a consistent RangeError (via tooLargeError) instead of producing malformed output (e.g., "undefined" segments). This aligns these language modules with the ongoing “fix-then-gate” hardening pattern across src/.

Changes:

  • Introduces derived magnitude limits (MAX_CARDINAL from SCALE.length, and a stricter MAX_ORDINAL) in both Hebrew variants.
  • Enforces the ceilings at the public entry points: toCardinal, toOrdinal, and toCurrency.
  • Uses the shared tooLargeError(maxExponent) helper for a uniform RangeError message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/he-IL.js Adds cardinal/currency (10^21) and ordinal (10^9) ceilings and throws tooLargeError(...) at public entry points.
src/hbo-IL.js Mirrors the same ceiling constants and entry-point guards for Biblical Hebrew.

@TylerVigario TylerVigario merged commit c401e6c into main Jun 4, 2026
8 checks passed
@TylerVigario TylerVigario deleted the fix/he-family-scale-ceilings branch June 4, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants