-
Notifications
You must be signed in to change notification settings - Fork 172
Normative: Disallow adding weeks, days, and time units to PlainYearMonth #3253
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
Conversation
|
This PR achieved consensus during TC39 plenary yesterday (2025-01-20) 🎉 |
Durations with units lower than months are no longer allowed. (The lower units may be present but 0.) Adjust the existing PlainYearMonth addition tests to test this behaviour and delete tests that are now irrelevant. Normative change: tc39/proposal-temporal#3253 Approved in 2026-01 TC39 plenary.
Durations with units lower than months are no longer allowed. (The lower units may be present but 0.) Adjust the existing PlainYearMonth addition tests to test this behaviour and delete tests that are now irrelevant. Normative change: tc39/proposal-temporal#3253 Approved in 2026-01 TC39 plenary.
Durations with units lower than months are no longer allowed. (The lower units may be present but 0.) Adjust the existing PlainYearMonth addition tests to test this behaviour and delete tests that are now irrelevant. Normative change: tc39/proposal-temporal#3253 Approved in 2026-01 TC39 plenary.
|
Test262 tests in tc39/test262#4883 |
Durations with units lower than months are no longer allowed. (The lower units may be present but 0.) Adjust the existing PlainYearMonth addition tests to test this behaviour and delete tests that are now irrelevant. Normative change: tc39/proposal-temporal#3253 Approved in 2026-01 TC39 plenary.
Durations with units lower than months are no longer allowed. (The lower units may be present but 0.) Adjust the existing PlainYearMonth addition tests to test this behaviour and delete tests that are now irrelevant. Normative change: tc39/proposal-temporal#3253 Approved in 2026-01 TC39 plenary.
|
Anything stopping us landing this? |
|
Slash would it be bad if I implemented this in V8 now instead of waiting? |
|
FWIW, the current placement of the check is quite awkward for V8 order-of-operations, because it's doing further validation of an input before other inputs are parsed. boa-dev/temporal#671 is our temporal_rs implementation, https://chromium-review.googlesource.com/c/v8/v8/+/7528669 uplifts to V8, and https://chromium-review.googlesource.com/c/v8/v8/+/7527580 duplicates that check in V8 for order-of-operations reasons. |
Just waiting for #3256 and #3263, since it's convenient to pull in changes at the same time as pulling in the test262 commit that tests them. Those are landed as of today.
For future reference, it would have made things a lot easier to have this feedback before the plenary! But you're right, it doesn't fit with the precedent we set in #3130. I'm assuming it's OK to incorporate this implementation feedback before landing this PR. |
This feature has been buggy for years and nobody noticed, so it must not be used very often. This is an alternative solution to fix the bug in issue #3197 and would supersede #3208 if accepted. This changes PlainYearMonth.prototype.add/subtract to throw a RangeError if the supplied duration has nonzero weeks, days, or time units. (Only years and months are allowed.) This does not change the behaviour of PlainDate.prototype.add/subtract, because there are more use cases for adding e.g. { hours: 48 }, and days are always 24 hours in PlainDate. Closes: #3197
b8409e4 to
faae30c
Compare
|
Updated. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3253 +/- ##
=======================================
Coverage 97.94% 97.94%
=======================================
Files 22 22
Lines 10408 10408
Branches 1816 1816
=======================================
Hits 10194 10194
Misses 196 196
Partials 18 18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The recent normative change disallowing addition of weeks and lower units (tc39/proposal-temporal#3253) should be implemented such that the exception is thrown after all options are read and cast.
|
Additional test coverage for the order of operations in tc39/test262#4894 |
I'm usually not implementing things until they land or there's relative certainty that they will land (for example, from the presence of test262 tests), so I wouldn't have really had an opportunity until now. I could try and review future changes for this type of thing but I also just didn't expect changes like this at this stage. |
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.
Spec text looks good. Current implementation expectedly fails a bunch of test262 tests, but I haven't yet tried to update V8's test262 pin.
|
test262 commit 1115529eaccb7411b11834efbd0551dbd04f42cd passes with https://chromium-review.googlesource.com/c/v8/v8/+/7528669 with the added SKIPs removed. |
The recent normative change disallowing addition of weeks and lower units (tc39/proposal-temporal#3253) should be implemented such that the exception is thrown after all options are read and cast.
This feature has been buggy for years and nobody noticed, so it must not be used very often. This is an alternative solution to fix the bug in issue #3197 and would supersede #3208 if accepted.
This changes PlainYearMonth.prototype.add/subtract to throw a RangeError if the supplied duration has nonzero weeks, days, or time units. (Only years and months are allowed.)
This does not change the behaviour of PlainDate.prototype.add/subtract, because there are more use cases for adding e.g.
{ hours: 48 }, and days are always 24 hours in PlainDate.Closes: #3197