-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: Limit valid values for DurationFormats to match upcoming limits in Temporal #173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not involved enough with this proposal to approve the change, but the limits are aligned with the normative change that was approved in Temporal.
2023-11-28: This PR achieved TC39-TG1 consensus. |
…oming limits in Temporal" Update tests for <tc39/proposal-intl-duration-format#173>.
Test coverage → tc39/test262#3988 |
c3a8180
to
2ffc85d
Compare
Updated to match limits currently set in Temporal. See: tc39/proposal-temporal#2727 @ptomato has pointed me toward tc39/proposal-temporal#2727 (comment) for thoughts on implementation. He's also written a polyfill that implements the limits via string manipulation to run test262 tests against. |
Note the text in Temporal PR 2727 was not the latest, Anba made some changes to it afterwards. |
fd04648
to
afe40c3
Compare
Just pushed a corrected version. Thanks for catching that! |
Does this change mean BigInt math is not required (just like in Temporal)? |
Could we do the following change to better match Temporal?
to
and change this part to be the exact text of 7.5.15 IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds ) |
Notice, with the PR , some test cases in will be invalid and require changes to test the boundary condition and throwing/not throwing in the correct values |
afe40c3
to
6a7767a
Compare
be1d641
to
eb5f6e6
Compare
… for Temporal.Duration. This commit applies the same limits on valid values for Intl.DurationFormat DurationRecords.
…oming limits in Temporal" Update tests for <tc39/proposal-intl-duration-format#173>.
…oming limits in Temporal" Update tests for <tc39/proposal-intl-duration-format#173>.
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by NOBODY (OOPS!). To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. This patch implements that specification. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h:
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by NOBODY (OOPS!). To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. This patch implements that specification. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h:
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by NOBODY (OOPS!). To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. The current JSC doesn't implement the limits for both `Intl.DurationFormat` and `Temporal.Duration`. This patch implements that specifications. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h:
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by NOBODY (OOPS!). To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. The current JSC doesn't implement the limits for both `Intl.DurationFormat` and `Temporal.Duration`. This patch implements that specifications. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h:
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by Yusuke Suzuki. To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. The current JSC doesn't implement the limits for both `Intl.DurationFormat` and `Temporal.Duration`. This patch implements that specifications. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h: Canonical link: https://commits.webkit.org/285131@main
https://bugs.webkit.org/show_bug.cgi?id=281394 Reviewed by Yusuke Suzuki. To align with the behavior of `Temporal.Duration`, a value limit has been added to `Intl.DurationFormat`[1]. The current JSC doesn't implement the limits for both `Intl.DurationFormat` and `Temporal.Duration`. This patch implements that specifications. In the spec, this limit is represented as a double based on seconds. However, to avoid rounding errors, we represent it as an `Int128` based on nanoseconds. [1]: tc39/proposal-intl-duration-format#173 (shouldThrow): (const.df.new.Intl.DurationFormat): (RangeError.shouldThrow): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::Duration::normalizedNanoseconds const): (JSC::ISO8601::absInt128): (JSC::ISO8601::isValidDuration): * Source/JavaScriptCore/runtime/ISO8601.h: Canonical link: https://commits.webkit.org/285131@main
See #157
Upcoming revisions to Temporal will limit the valid values for Temporal.Duration. This commit applies the same limits on valid values for Intl.DurationFormat DurationRecords. Specifically: the absolute values of the values stored in each of the [[Years]], [[Months]], and [[Weeks]] fields cannot exceed 2^32, and the absolute value of the value obtained through converting the values in each of the sub-week fields to seconds and then summing them must not exceed 2^53.