Skip to content

Commit

Permalink
Normative: make async iterators next/return/throw not pass `undefined…
Browse files Browse the repository at this point in the history
…` when value is absent (tc39#1776)
  • Loading branch information
ljharb committed Jun 15, 2020
1 parent f8e7557 commit ff4ea13
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -38832,20 +38832,23 @@ <h1>The %AsyncFromSyncIteratorPrototype% Object</h1>
</ul>

<emu-clause id="sec-%asyncfromsynciteratorprototype%.next">
<h1>%AsyncFromSyncIteratorPrototype%.next ( _value_ )</h1>
<h1>%AsyncFromSyncIteratorPrototype%.next ( [ _value_ ] )</h1>
<emu-alg>
1. Let _O_ be the *this* value.
1. Assert: Type(_O_) is Object and _O_ has a [[SyncIteratorRecord]] internal slot.
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Let _syncIteratorRecord_ be _O_.[[SyncIteratorRecord]].
1. Let _result_ be IteratorNext(_syncIteratorRecord_, _value_).
1. If _value_ is present, then
1. Let _result_ be IteratorNext(_syncIteratorRecord_, _value_).
1. Else,
1. Let _result_ be IteratorNext(_syncIteratorRecord_).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. Return ! AsyncFromSyncIteratorContinuation(_result_, _promiseCapability_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-%asyncfromsynciteratorprototype%.return">
<h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1>
<h1>%AsyncFromSyncIteratorPrototype%.return ( [ _value_ ] )</h1>

<emu-alg>
1. Let _O_ be the *this* value.
Expand All @@ -38858,7 +38861,10 @@ <h1>%AsyncFromSyncIteratorPrototype%.return ( _value_ )</h1>
1. Let _iterResult_ be ! CreateIterResultObject(_value_, *true*).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, &laquo; _iterResult_ &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Let _result_ be Call(_return_, _syncIterator_, &laquo; _value_ &raquo;).
1. If _value_ is present, then
1. Let _result_ be Call(_return_, _syncIterator_, &laquo; _value_ &raquo;).
1. Else,
1. Let _result_ be Call(_return_, _syncIterator_, &laquo; &raquo;).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
Expand All @@ -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>

<emu-alg>
1. Let _O_ be the *this* value.
Expand All @@ -38880,7 +38886,10 @@ <h1>%AsyncFromSyncIteratorPrototype%.throw ( _value_ )</h1>
1. If _throw_ is *undefined*, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; _value_ &raquo;).
1. Return _promiseCapability_.[[Promise]].
1. Let _result_ be Call(_throw_, _syncIterator_, &laquo; _value_ &raquo;).
1. If _value_ is present, then
1. Let _result_ be Call(_throw_, _syncIterator_, &laquo; _value_ &raquo;).
1. Else,
1. Let _result_ be Call(_throw_, _syncIterator_, &laquo; &raquo;).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. If Type(_result_) is not Object, then
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; a newly created *TypeError* object &raquo;).
Expand Down

0 comments on commit ff4ea13

Please sign in to comment.