-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: make async iterators next/return/throw not pass undefined
when value is absent
#1776
Conversation
This comment has been minimized.
This comment has been minimized.
This PR achieved consensus at today's TC39. It will first require at least one browser implementation committing to implement it, and merged test262 tests, and it being web compatible before this PR can be merged. |
…` when value is absent (tc39#1776)
dcf16ce
to
0a6e461
Compare
@codehag has confirmed that SpiderMonkey is OK making the change, although we'll still have to wait for at least one shipping implementation due to web compat concerns. |
…` when value is absent (tc39#1776)
0a6e461
to
45ea73a
Compare
Tests PR: tc39/test262#2551 |
…` when value is absent (tc39#1776)
45ea73a
to
dc6d312
Compare
I will submit a patch for JSC as soon as the tests are merged & synced. EDIT Apr 30: |
…` when value is absent (tc39#1776)
dc6d312
to
7abcd0a
Compare
…e. r=yulia We're using a shared implementation for the "next", "return", and "throw" methods, so we only need to adjust a single line of code. Spec PR: tc39/ecma262#1776 Depends on D70815 Differential Revision: https://phabricator.services.mozilla.com/D70816
…e. r=yulia We're using a shared implementation for the "next", "return", and "throw" methods, so we only need to adjust a single line of code. Spec PR: tc39/ecma262#1776 Depends on D70815 Differential Revision: https://phabricator.services.mozilla.com/D70816 --HG-- extra : moz-landing-system : lando
…` when value is absent (tc39#1776)
7abcd0a
to
6c5f201
Compare
Given that Firefox ships this and the next version of Safari is likely to as well, this seems like sufficient web compat data to me. I'm going to remove the "needs data" label and rebase it; does anyone think that we should wait longer before landing it (modulo approvals)? |
…` when value is absent (tc39#1776)
6c5f201
to
ff4ea13
Compare
spec.html
Outdated
@@ -38868,7 +38874,7 @@ <h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1> | |||
</emu-clause> | |||
|
|||
<emu-clause id="sec-%asyncfromsynciteratorprototype%.throw"> | |||
<h1>%AsyncFromSyncIteratorPrototype%.throw ( _value_ )</h1> | |||
<h1>%AsyncFromSyncIteratorPrototype%.throw ( [ _value_ ] )</h1> |
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.
Can we add a NOTE explaining that this optional argument is, in fact, always passed? (Since AsyncFromSyncIteratorPrototype
objects are not user-observable and the only in-spec callsite, in yield *
, always passes an argument.)
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.
Sure, but can you help me understand the value of noting that when the entire % AsyncFromSyncIteratorPrototype%
object is already unobservable?
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.
Because it is unobservable, it's basically an abstract operation. By comparison, all abstract operations are unobservable, but it would still be surprising to define an abstract operation which took an optional parameter which was, in fact, always passed.
Here I don't really mind marking the parameter as optional and having logic for what to do if the argument is not passed (though now that I write this I guess I'd be happier still if we just asserted it were, but whatever), but since it's surprising, I think it would benefit from a NOTE.
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.
Note added.
…` when value is absent (tc39#1776)
ff4ea13
to
efa5a78
Compare
…e methods tc39/ecma262#1776 is a normative change that reached consensus in the November 2019 TC39. It changes %AsyncFromSyncIteratorPrototype% methods to forward the absence of arguments to the underlying sync iterator. This is observable via `arguments.length` inside the underlying sync iterator. For example, .next is changed to, roughly: ``` %AsyncFromSyncIteratorPrototype%.next = function(value) { let res; if (arguments.length < 1) { res = [[SyncIteratorRecord]].[[Iterator]].next(); } else { res = [[SyncIteratorRecord]].[[Iterator]].next(value); } // ... }; ``` Bug: v8:10395 Change-Id: Ib8127d08cd78b8d502e6510241f3f13fbbaba5c7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2247041 Reviewed-by: Marja Hölttä <marja@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/master@{#68398}
…` when value is absent (tc39#1776)
efa5a78
to
7fef32f
Compare
…` when value is absent (tc39#1776)
7fef32f
to
18c134e
Compare
This is admittedly a very minor change.
logs
'args', []
logs
'args', [undefined]
. The intention of this change is to make async iteration match sync iteration from the perspective of a userland iteratornext
method.This was an intentional decision made by the feature champion in tc39/proposal-async-iteration#113, but I don't recall it being discussed in committee. I find this inconsistency mildly troubling, and would like to correct it.
It has relevance as well for the "iterator helpers" proposal.