Skip to content

Commit

Permalink
Editorial: set iterator record [[Done]] inside IteratorStepValue
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Jan 25, 2024
1 parent 1989b13 commit be7ec12
Showing 1 changed file with 33 additions and 64 deletions.
97 changes: 33 additions & 64 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7005,10 +7005,21 @@ <h1>
<dd>It requests the next value from _iteratorRecord_.[[Iterator]] by calling _iteratorRecord_.[[NextMethod]] and returns either *false* indicating that the iterator has reached its end or the value from the iterator result object if a next value is available.</dd>
</dl>
<emu-alg>
1. Let _result_ be ? IteratorNext(_iteratorRecord_).
1. Let _done_ be ? IteratorComplete(_result_).
1. If _done_ is *true*, return ~done~.
1. Return ? Get(_result_, *"value"*).
1. Let _result_ be Completion(IteratorNext(_iteratorRecord_)).
1. If _result_ is an abrupt completion, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Return ? _result_.
1. Let _done_ be Completion(IteratorComplete(_result_)).
1. If _done_ is an abrupt completion, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Return ? _done_.
1. If _done_ is *true*, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Return ~done~.
1. Let _value_ be Completion(Get(_result_, *"value"*)).
1. If _value_ is an abrupt completion, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Return ? _value_.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -9572,12 +9583,8 @@ <h1>
1. Let _lhs_ be ? ResolveBinding(_bindingId_, _environment_).
1. Let _v_ be *undefined*.
1. If _iteratorRecord_.[[Done]] is *false*, then
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Set _v_ to _next_.
1. If |Initializer| is present and _v_ is *undefined*, then
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then
Expand All @@ -9592,12 +9599,8 @@ <h1>
<emu-alg>
1. Let _v_ be *undefined*.
1. If _iteratorRecord_.[[Done]] is *false*, then
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Set _v_ to _next_.
1. If |Initializer| is present and _v_ is *undefined*, then
1. Let _defaultValue_ be ? Evaluation of |Initializer|.
Expand All @@ -9611,10 +9614,7 @@ <h1>
1. Let _n_ be 0.
1. Repeat,
1. If _iteratorRecord_.[[Done]] is *false*, then
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, set _iteratorRecord_.[[Done]] to *true*.
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _iteratorRecord_.[[Done]] is *true*, then
1. If _environment_ is *undefined*, return ? PutValue(_lhs_, _A_).
1. Return ? InitializeReferencedBinding(_lhs_, _A_).
Expand All @@ -9627,10 +9627,7 @@ <h1>
1. Let _n_ be 0.
1. Repeat,
1. If _iteratorRecord_.[[Done]] is *false*, then
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, set _iteratorRecord_.[[Done]] to *true*.
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _iteratorRecord_.[[Done]] is *true*, then
1. Return ? BindingInitialization of |BindingPattern| with arguments _A_ and _environment_.
1. Perform ! CreateDataPropertyOrThrow(_A_, ! ToString(𝔽(_n_)), _next_).
Expand All @@ -9654,12 +9651,8 @@ <h1>
<emu-alg>
1. Let _v_ be *undefined*.
1. Assert: _iteratorRecord_.[[Done]] is *false*.
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Set _v_ to _next_.
1. Return ? BindingInitialization of |BindingIdentifier| with arguments _v_ and _environment_.
</emu-alg>
Expand All @@ -9674,12 +9667,8 @@ <h1>
<emu-alg>
1. Let _v_ be *undefined*.
1. Assert: _iteratorRecord_.[[Done]] is *false*.
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Set _v_ to _next_.
1. Return ? BindingInitialization of |BindingIdentifier| with arguments _v_ and _environment_.
</emu-alg>
Expand Down Expand Up @@ -21009,12 +20998,8 @@ <h1>
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
1. Let _lref_ be ? Evaluation of |DestructuringAssignmentTarget|.
1. If _iteratorRecord_.[[Done]] is *false*, then
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Let _value_ be _next_.
1. If _iteratorRecord_.[[Done]] is *true*, let _value_ be *undefined*.
1. If |Initializer| is present and _value_ is *undefined*, then
Expand All @@ -21040,12 +21025,8 @@ <h1>
1. Let _A_ be ! ArrayCreate(0).
1. Let _n_ be 0.
1. Repeat, while _iteratorRecord_.[[Done]] is *false*,
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Else,
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is not ~done~, then
1. Perform ! CreateDataPropertyOrThrow(_A_, ! ToString(𝔽(_n_)), _next_).
1. Set _n_ to _n_ + 1.
1. If |DestructuringAssignmentTarget| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then
Expand Down Expand Up @@ -46648,11 +46629,8 @@ <h1>
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
1. Let _index_ be 0.
1. Repeat,
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
1. If _remainingElementsCount_.[[Value]] = 0, then
1. Let _valuesArray_ be CreateArrayFromList(_values_).
Expand Down Expand Up @@ -46733,11 +46711,8 @@ <h1>
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
1. Let _index_ be 0.
1. Repeat,
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
1. If _remainingElementsCount_.[[Value]] = 0, then
1. Let _valuesArray_ be CreateArrayFromList(_values_).
Expand Down Expand Up @@ -46857,11 +46832,8 @@ <h1>
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
1. Let _index_ be 0.
1. Repeat,
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1.
1. If _remainingElementsCount_.[[Value]] = 0, then
1. Let _error_ be a newly created *AggregateError* object.
Expand Down Expand Up @@ -46950,11 +46922,8 @@ <h1>
</dl>
<emu-alg>
1. Repeat,
1. Let _next_ be Completion(IteratorStepValue(_iteratorRecord_)).
1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*.
1. ReturnIfAbrupt(_next_).
1. Let _next_ be ? IteratorStepValue(_iteratorRecord_).
1. If _next_ is ~done~, then
1. Set _iteratorRecord_.[[Done]] to *true*.
1. Return _resultCapability_.[[Promise]].
1. Let _nextPromise_ be ? Call(_promiseResolve_, _constructor_, « _next_ »).
1. Perform ? Invoke(_nextPromise_, *"then"*, « _resultCapability_.[[Resolve]], _resultCapability_.[[Reject]] »).
Expand Down

0 comments on commit be7ec12

Please sign in to comment.