-
Notifications
You must be signed in to change notification settings - Fork 153
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: Remove duplicates in PrepareTemporalFields #2570
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2570 +/- ##
==========================================
+ Coverage 95.98% 96.15% +0.17%
==========================================
Files 20 20
Lines 11574 11275 -299
Branches 2201 2159 -42
==========================================
- Hits 11109 10842 -267
+ Misses 401 369 -32
Partials 64 64
|
This change achieved consensus in the May 2023 TC39 plenary meeting, including the latest revisions. We'll need to pull in test262 tests before merging it. |
It should be an error to return duplicate fields in a Calendar's field() method, thus we throw if we encounter one in PrepareTemporalFields. There are two cases (PlainMonthDay.prototype.toPlainDate and PlainYearMonth.prototype.toPlainDate) where, after checking on the return values of field() in previous invocations of PrepareTemporalFields, we want to deduplicate the field name list in a later call to PrepareTemporalFields after concatenating them, since we sort them in PrepareTemporalFields. For this reason, we add a duplicateBehavior parameter to PrepareTemporalFields. This allows us to remove the MergeLists abstract operation, now replaced by a simple list concatenation and deduplication in PrepareTemporalFields with duplicateBehavior set to ignore. It should also be an error to return field names 'constructor' or '__proto__' in a Calendar's field() method, and we throw if that happens. Fixes tc39#2532, 2576.
* Add tests for the new PrepareTemporalFields behavior for all direct callers See tc39/proposal-temporal#2570 * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDate * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDateTime * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalZonedDateTime * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalYearMonth * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalMonthDay * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToRelativeTemporalObject * Add tests for the new PrepareTemporalFields behavior for indirect callers through AddDurationToOrSubtractDurationFromPlainYearMonth
Tests are in. |
…=allstarschh Implement the changes from <tc39/proposal-temporal#2570>. Differential Revision: https://phabricator.services.mozilla.com/D185408
…=allstarschh Implement the changes from <tc39/proposal-temporal#2570>. Differential Revision: https://phabricator.services.mozilla.com/D185408
Addresses #2532.
In some cases, duplicate property names are possible in PrepareTemporalFields(). Remove duplicates there, which removes the need for MergeLists(), which is replaced by a list-concatenation in the two places where it was used.
Updates PrepareTemporalFields() to remove duplicates, and {PlainYearMonth,PlainMonthDay}.prototype.toPlainDate() to use list-concatenation instead of MergeLists().
Removes MergeLists() as it's not used any more.
Updates polyfill to match the changes.