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

Various bugfixes and making things consistent #1393

Merged
merged 11 commits into from
Feb 26, 2021
Merged

Various bugfixes and making things consistent #1393

merged 11 commits into from
Feb 26, 2021

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Feb 26, 2021

Encountered while investigating #1294

This must have been left over from moving draft spec text out into the
Intl.DurationFormat proposal.
We added a fallback for mergeFields() several months ago but forgot to
note it in the documentation.
PlainTime doesn't have a calendar argument in its constructor.
This doesn't match the spec, and has different observable effects, so
should not be in the polyfill.
Previously, the returned object would always be an instance of
Temporal.ZonedDateTime even if the from() method was called on a subclass
of ZonedDateTime. This is a bug.

No change needed in the spec text, which already is correct here.
The spec text performs RequireInternalSlot on the returned value to ensure
that it's a Temporal.Instant. Do the same in the polyfill in order to be
spec-compliant.
The spec text does not say that toString() may be called here. Use the
internal slot if present to get the identifier. If that's not possible,
make the message generic.
We already call toString() once on the time zone in extractOverrides(),
and we don't need the actual time zone object subsequently, so return the
result of toString() from extractOverrides() instead of the time zone
object.

As far as I can tell this is already done correctly in the spec text.
The polyfill was validating the returned array in some cases but not
consistently. Create an abstract operation to call this method and
validate the result consistently, in order to be compliant with the spec
text.

Requires a small bug fix in the spec text (omitted argument on
CreateListFromArrayLike.)
This is a bug in the spec text. The calendar era() and eraYear() methods
take an object with [[ISOYear]], [[ISOMonth]], and [[ISODay]] internal
slots, which ZonedDateTime does not have.

No change needed to the polyfill which does this correctly.
This introduces a bunch of abstract operations, and brings the existing
ones in line with each other, to consistently use GetMethod (which throws
if the method isn't callable) to get the calendar methods off of the
calendar object. Any methods for which we have agreed that Temporal core
(and not the calendars) should validate the return value, are now also
consistently validated in these abstract operations.

Bring the spec text in line with this as well. Some of these abstract
operations existed, but weren't consistently used. (The exception to this
is where the method was fetched only once from the calendar object to be
called multiple times. This will be resolved one way or the other in
issue #1294.)
@codecov
Copy link

codecov bot commented Feb 26, 2021

Codecov Report

Merging #1393 (dd4a730) into main (658a12c) will increase coverage by 0.33%.
The diff coverage is 92.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1393      +/-   ##
==========================================
+ Coverage   95.36%   95.70%   +0.33%     
==========================================
  Files          19       19              
  Lines       11137    11140       +3     
  Branches     1829     1811      -18     
==========================================
+ Hits        10621    10661      +40     
+ Misses        511      476      -35     
+ Partials        5        3       -2     
Flag Coverage Δ
test262 48.71% <47.90%> (+0.32%) ⬆️
tests 91.50% <87.55%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/plaindatetime.mjs 95.50% <78.57%> (+2.06%) ⬆️
polyfill/lib/ecmascript.mjs 95.97% <91.66%> (-0.12%) ⬇️
polyfill/lib/plainyearmonth.mjs 95.34% <93.33%> (+0.74%) ⬆️
polyfill/lib/plaindate.mjs 96.03% <94.44%> (+1.42%) ⬆️
polyfill/lib/intl.mjs 100.00% <100.00%> (ø)
polyfill/lib/plainmonthday.mjs 90.64% <100.00%> (+1.81%) ⬆️
polyfill/lib/timezone.mjs 95.70% <100.00%> (+1.46%) ⬆️
polyfill/lib/zoneddatetime.mjs 97.93% <100.00%> (+0.80%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 658a12c...51e76f3. Read the comment docs.

Copy link
Collaborator

@cjtenny cjtenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, thanks for fixing these! I'm surprised it didn't require any tests changes. I don't think it's worth adding test/test262 changes right now for all of these (e.g. verifying that exceptions don't call timeZone.toString), but I think we should add tests (doesn't have to be now; test262 seems fine) for:

  • Properly checking callable on retrieved methods
  • That timeZone.getInstantFor properly throws on non-Temporal.Instant values
    (eventually). Do we have a list of 'things missing from the test262 tests' somewhere?

@ptomato
Copy link
Collaborator Author

ptomato commented Feb 26, 2021

Cam and I discussed that we do need to start keeping a checklist of things that need to be test262'd.

@ptomato ptomato merged commit 4b4c8ca into main Feb 26, 2021
@ptomato ptomato deleted the various-bugfixes branch February 26, 2021 22:01
@cjtenny cjtenny mentioned this pull request Feb 27, 2021
44 tasks
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.

2 participants