Skip to content
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

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

guijemont
Copy link
Collaborator

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.

@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #2570 (3ce7b32) into main (736d6db) will increase coverage by 0.17%.
The diff coverage is 100.00%.

❗ Current head 3ce7b32 differs from pull request most recent head 98e6746. Consider uploading reports for the commit 98e6746 to get more accurate results

@@            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              
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 98.17% <100.00%> (-0.09%) ⬇️
polyfill/lib/plainmonthday.mjs 97.50% <100.00%> (-0.27%) ⬇️
polyfill/lib/plainyearmonth.mjs 98.27% <100.00%> (-0.13%) ⬇️

... and 6 files with indirect coverage changes

@ptomato ptomato marked this pull request as ready for review May 17, 2023 19:48
@ptomato
Copy link
Collaborator

ptomato commented May 17, 2023

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.

guijemont added a commit to guijemont/test262 that referenced this pull request Jun 20, 2023
@ptomato ptomato mentioned this pull request Jul 13, 2023
91 tasks
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.
ptomato pushed a commit to guijemont/test262 that referenced this pull request Jul 17, 2023
ptomato pushed a commit to tc39/test262 that referenced this pull request Jul 17, 2023
* 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
@ptomato
Copy link
Collaborator

ptomato commented Jul 17, 2023

Tests are in.

@ptomato ptomato merged commit 8b80732 into tc39:main Jul 17, 2023
5 checks passed
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 13, 2023
vinnydiehl pushed a commit to vinnydiehl/mozilla-unified that referenced this pull request Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants