Skip to content

Commit d4e624c

Browse files
Ralphclaude
andcommitted
fix(intl): #5585 — ECMA-402 option/locale validation for the six small constructors
Brings the small Intl constructors (Collator, Segmenter, ListFormat, RelativeTimeFormat, PluralRules) up to spec on option coercion, locale-list handling, and a few behavioral gaps. test262 intl402 parity across these six dirs goes from 241/387 (62%) to 297/387 (77%) — 56 cases fixed, no regressions. Shared helpers (intl.rs): - `get_option_string_coerced` / `enum_option_strict` — GetOption with full ToString coercion (null → "null", Symbol → TypeError), so `options-*-invalid` values are rejected instead of silently defaulting. - `get_options_object` (GetOptionsObject: non-Object/non-undefined → TypeError) and `coerce_options_reject_null` (ToObject: null → TypeError), wired per the spec step each constructor uses. - `locales_from_value` now follows CanonicalizeLocaleList: null → TypeError, array-like Objects are iterated (`{0:"DE",length:1}` → `["de"]`), element type-checks throw TypeError, and a throwing/Symbol `length` propagates. - `supportedLocalesOf` validates its `options` arg (localeMatcher) and filters the request list through a BestAvailableLocale check, so the result length matches (e.g. `zxx` is dropped). - Per-constructor: read `localeMatcher` (+ `numberingSystem` for RTF) in the exact GetOption order the `options-order` / read-order tests assert. Collator (date_collator.rs): - NFD-normalize before comparing so canonically-equivalent strings collate 0. - Resolve `numeric`/`caseFirst`/`collation` from options or the locale's `-u-kn`/`-u-kf`/`-u-co` extension keywords; reflect them (plus `usage`, `sensitivity`, `ignorePunctuation`, `collation`) in resolvedOptions in spec order. `ignorePunctuation` now strips ignorable punctuation in compare. RelativeTimeFormat / PluralRules (list_relative_plural.rs): - RTF format/formatToParts use full ToNumber (Symbol → TypeError, object valueOf honoured); units are case-sensitive; formatToParts attaches the `unit` field to the numeric parts. - PluralRules reads options in SetNumberFormatDigitOptions order, adds `notation`/`compactDisplay`, and `selectRange` throws TypeError for undefined or Symbol arguments. Out of scope (still failing, need CLDR data or larger runtime work): locale- specific formatting/collation, the prototype accessor-getter shape for compare/format, %Segments.prototype%.containing, subclassing/new.target, and @@toStringTag inheritance on instances. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c9d156b commit d4e624c

3 files changed

Lines changed: 481 additions & 48 deletions

File tree

0 commit comments

Comments
 (0)