fix(runtime): #5582 — coerce null Intl option values per GetOption (10 test262)#5729
Conversation
…(10 test262) ECMA-402 GetOption treats only `undefined` as "absent → use fallback"; every other value, `null` included, is coerced with ToString and validated. Perry's `get_option_string` short-circuited `null` to `None`, so a `null` enum option (localeMatcher, formatMatcher, weekday, hourCycle, dateStyle, style, type, numeric, currencyDisplay, roundingPriority, …) was silently ignored instead of surfacing as the string "null", failing the allow-list, and raising a RangeError. Now `null` coerces to "null" like any other ToString-able value. For the Unicode locale-extension keys (`calendar`, `numberingSystem`) "null" is a well-formed but unsupported `type` subtag, so ResolveLocale drops it and resolvedOptions reports the locale default — a new `get_locale_extension_option` mirrors that observable outcome by treating `null` as absent rather than echoing "null". The property getter is read exactly once so the GetOption call-order tests (constructor-calendar-numberingSystem-order.js) still pass. Net test262 intl402 (DateTimeFormat/NumberFormat/ListFormat/PluralRules/ RelativeTimeFormat/Locale): +10 pass, 0 regressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntl option coercion now distinguishes ChangesIntl DateTimeFormat null option handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Addresses part of #5582 (test262 intl402 DateTimeFormat parity). ECMA-402 GetOption treats only
undefinedas "absent → use the fallback"; every other value —nullincluded — is coerced withToStringand then validated. Perry'sget_option_stringshort-circuitednulltoNone, so anullenum option was silently ignored instead of being rejected.With this fix
nullcoerces to the string"null", which:localeMatcher,formatMatcher,weekday,hourCycle,dateStyle, and the NumberFormat / ListFormat / RelativeTimeFormat enums (style,type,numeric,currencyDisplay,roundingPriority, …); andcalendar/numberingSystem,"null"is a well-formed but unsupportedtypesubtag, so ResolveLocale drops it andresolvedOptionsreports the locale default (gregory/latn). A smallget_locale_extension_optionmirrors that observable outcome by treatingnullas absent rather than echoing"null". It reads the option getter exactly once so the GetOption call-order tests still pass.Validation
Local test262 sweep (pinned sha
4249661, Node v26.3.0 oracle,scripts/test262_subset.py) acrossintl402/{DateTimeFormat,NumberFormat,ListFormat,PluralRules,RelativeTimeFormat,Locale}:+10 pass, 0 regressions (321 → 311 runtime-fails).
Fixed:
Added gap test
test-files/test_gap_intl_datetimeformat_null_option_5582.ts, which is byte-identical againstnode --experimental-strip-types.🤖 Generated with Claude Code
Summary by CodeRabbit
Intl.DateTimeFormathandling fornulloption values.nullis now treated as absent forcalendarandnumberingSystem, preventing errors and allowing locale-based fallback.nullstill handled consistently.