[webkit-changes] [WebKit/WebKit] a43717: [JSC] `Intl.DurationFormat#resolvedOptions().fract...

SUZUKI Sosuke noreply at github.com
Thu May 30 00:49:13 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a43717459fdb2af1b6dee3dbdb68488943c17710
      https://github.com/WebKit/WebKit/commit/a43717459fdb2af1b6dee3dbdb68488943c17710
  Author: Sosuke Suzuki <aosukeke at gmail.com>
  Date:   2024-05-30 (Thu, 30 May 2024)

  Changed paths:
    A JSTests/stress/intl-durationformat-fractionaldigits-undefined.js
    M JSTests/stress/intl-durationformat.js
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp

  Log Message:
  -----------
  [JSC] `Intl.DurationFormat#resolvedOptions().fractionalDigits` should be `undefined` if `fractionalDigits` is `undefined`.
https://bugs.webkit.org/show_bug.cgi?id=274733

Reviewed by Ross Kirsling.

According to the spec[1], when creating a `DurationFormat` instance with
`new Intl.DurationFormat(locales, { fractionalDigits: undefined });`,
`Intl.DurationFormat#resolvedOptions().fractionalDigits` should be `undefined`. However, in the
current JSC, it is `0`. This was occurring because, according to the spec[2], the
`fallback` argument of the `GetNumberOption` abstract operation should be `undefined`, but we were
passing `0`.

This patch makes the following changes:

- Pass `numeric_limits<unsigned>::max()`, representing `undefined`, to the `fallback` argument of
the `intlNumberOption`
function, which corresponds to the `GetNumberOption` abstract operation, when initializing
`DurationFormat` instances.
- In the `DurationFormat#resolvedOption` function, set the `fractionalDigits` field to
`jsUndefined()` if `m_fractionalDigits` is `numeric_limits<unsigned>::max()`.

[1]: https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.resolvedOptions
[2]: https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat

* JSTests/stress/intl-durationformat-fractionaldigits-undefined.js: Added.
(shouldBe):
* JSTests/stress/intl-durationformat.js:
(test):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/runtime/IntlDurationFormat.cpp:
(JSC::IntlDurationFormat::initializeDurationFormat):
(JSC::collectElements):
(JSC::IntlDurationFormat::resolvedOptions const):

Canonical link: https://commits.webkit.org/279503@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list