fix(i18n): read a fraction with a decimal numerator as a duration #289

Merged
abiwab merged 1 commit from fix/duration-decimal-numerator-fraction into main 2026-11-26 21:40:35 +01:00
Owner

Follow-up noted in #286.

The parser reads a decimal numerator as a fraction ({1.5/2 cups} is 0.75 cup, conformance case 025, fixed in 1.0.0-beta5), but a timer's duration is read from its raw text by parseDuration (@gram-lang/i18n), whose tokenizer took 1.5 as a decimal and stopped at the /: ~{1.5/2 min} got INVALID_DURATION and counted for nothing in the schedule.

  • tokenizeDuration: a decimal followed by / and digits is a fraction (1.5/2, 1,5/2). The denominator stays whole and a mixed number needs a whole numerator, as the grammar's plainNumber and mixedFraction (1/2.5 h is still refused, 1 0.5/2 hour gives bareNumber).
  • Tests: 5 cases in the reference table packages/i18n/tests/duration-cases.ts (en + fr; 4 fail without the fix, 1/2.5 h is a guard), and packages/kitchen/tests/decimal-numerator-timer.test.ts (simple and proportional timers; both fail without the fix).
  • patch changeset for @gram-lang/i18n and @gram-lang/kitchen.

Checks: 3944 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, deprecations:check, audit 126.

Fuzz 50k (seed 1572729094): one format-idempotent signature, a regression of #285 already on main, unrelated to this change; fixed in a separate PR.

Follow-up noted in #286. The parser reads a decimal numerator as a fraction (`{1.5/2 cups}` is 0.75 cup, conformance case 025, fixed in 1.0.0-beta5), but a timer's duration is read from its raw text by `parseDuration` (`@gram-lang/i18n`), whose tokenizer took `1.5` as a decimal and stopped at the `/`: `~{1.5/2 min}` got `INVALID_DURATION` and counted for nothing in the schedule. - `tokenizeDuration`: a decimal followed by `/` and digits is a fraction (`1.5/2`, `1,5/2`). The denominator stays whole and a mixed number needs a whole numerator, as the grammar's `plainNumber` and `mixedFraction` (`1/2.5 h` is still refused, `1 0.5/2 hour` gives `bareNumber`). - Tests: 5 cases in the reference table `packages/i18n/tests/duration-cases.ts` (en + fr; 4 fail without the fix, `1/2.5 h` is a guard), and `packages/kitchen/tests/decimal-numerator-timer.test.ts` (simple and proportional timers; both fail without the fix). - `patch` changeset for `@gram-lang/i18n` and `@gram-lang/kitchen`. Checks: 3944 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, `deprecations:check`, audit 126. Fuzz 50k (seed 1572729094): one `format-idempotent` signature, a regression of #285 already on main, unrelated to this change; fixed in a separate PR.
fix(i18n): read a fraction with a decimal numerator as a duration
All checks were successful
CI / Build & Test (pull_request) Successful in 6m19s
ccdbca77a1
abiwab merged commit 00caedf72e into main 2026-11-26 21:40:35 +01:00
abiwab deleted branch fix/duration-decimal-numerator-fraction 2026-11-26 21:40:36 +01:00
Sign in to join this conversation.
No description provided.