Skip to content

Commit 4cb5a69

Browse files
committed
Normative: guard against reentrancy in AsyncGenerator.prototype.return
1 parent bf2e2fe commit 4cb5a69

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

spec.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48461,7 +48461,7 @@ <h1>
4846148461
1. Let _result_ be Completion(_generatorBody_()).
4846248462
1. Assert: If we return here, the async generator either threw an exception or performed either an implicit or explicit return.
4846348463
1. Remove _acGenContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context.
48464-
1. Set _acGenerator_.[[AsyncGeneratorState]] to ~completed~.
48464+
1. Set _acGenerator_.[[AsyncGeneratorState]] to ~awaiting-return~.
4846548465
1. If _result_ is a normal completion, set _result_ to NormalCompletion(*undefined*).
4846648466
1. If _result_ is a return completion, set _result_ to NormalCompletion(_result_.[[Value]]).
4846748467
1. Perform AsyncGeneratorCompleteStep(_acGenerator_, _result_, *true*).
@@ -48626,28 +48626,28 @@ <h1>
4862648626
<dl class="header">
4862748627
</dl>
4862848628
<emu-alg>
48629+
1. Assert: _generator_.[[AsyncGeneratorState]] is ~awaiting-return~.
4862948630
1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]].
4863048631
1. Assert: _queue_ is not empty.
4863148632
1. Let _next_ be the first element of _queue_.
4863248633
1. Let _completion_ be Completion(_next_.[[Completion]]).
4863348634
1. Assert: _completion_ is a return completion.
4863448635
1. Let _promiseCompletion_ be Completion(PromiseResolve(%Promise%, _completion_.[[Value]])).
4863548636
1. If _promiseCompletion_ is an abrupt completion, then
48636-
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
4863748637
1. Perform AsyncGeneratorCompleteStep(_generator_, _promiseCompletion_, *true*).
4863848638
1. Perform AsyncGeneratorDrainQueue(_generator_).
4863948639
1. Return ~unused~.
4864048640
1. Assert: _promiseCompletion_ is a normal completion.
4864148641
1. Let _promise_ be _promiseCompletion_.[[Value]].
4864248642
1. Let _fulfilledClosure_ be a new Abstract Closure with parameters (_value_) that captures _generator_ and performs the following steps when called:
48643-
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
48643+
1. Assert: _generator_.[[AsyncGeneratorState]] is ~awaiting-return~.
4864448644
1. Let _result_ be NormalCompletion(_value_).
4864548645
1. Perform AsyncGeneratorCompleteStep(_generator_, _result_, *true*).
4864648646
1. Perform AsyncGeneratorDrainQueue(_generator_).
4864748647
1. Return *undefined*.
4864848648
1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledClosure_, 1, *""*, « »).
4864948649
1. Let _rejectedClosure_ be a new Abstract Closure with parameters (_reason_) that captures _generator_ and performs the following steps when called:
48650-
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
48650+
1. Assert: _generator_.[[AsyncGeneratorState]] is ~awaiting-return~.
4865148651
1. Let _result_ be ThrowCompletion(_reason_).
4865248652
1. Perform AsyncGeneratorCompleteStep(_generator_, _result_, *true*).
4865348653
1. Perform AsyncGeneratorDrainQueue(_generator_).
@@ -48669,22 +48669,25 @@ <h1>
4866948669
<dd>It drains the generator's AsyncGeneratorQueue until it encounters an AsyncGeneratorRequest which holds a return completion.</dd>
4867048670
</dl>
4867148671
<emu-alg>
48672-
1. Assert: _generator_.[[AsyncGeneratorState]] is ~completed~.
48672+
1. Assert: _generator_.[[AsyncGeneratorState]] is ~awaiting-return~.
4867348673
1. Let _queue_ be _generator_.[[AsyncGeneratorQueue]].
48674-
1. If _queue_ is empty, return ~unused~.
48674+
1. If _queue_ is empty, then
48675+
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
48676+
1. Return ~unused~.
4867548677
1. Let _done_ be *false*.
4867648678
1. Repeat, while _done_ is *false*,
4867748679
1. Let _next_ be the first element of _queue_.
4867848680
1. Let _completion_ be Completion(_next_.[[Completion]]).
4867948681
1. If _completion_ is a return completion, then
48680-
1. Set _generator_.[[AsyncGeneratorState]] to ~awaiting-return~.
4868148682
1. Perform AsyncGeneratorAwaitReturn(_generator_).
4868248683
1. Set _done_ to *true*.
4868348684
1. Else,
4868448685
1. If _completion_ is a normal completion, then
4868548686
1. Set _completion_ to NormalCompletion(*undefined*).
4868648687
1. Perform AsyncGeneratorCompleteStep(_generator_, _completion_, *true*).
48687-
1. If _queue_ is empty, set _done_ to *true*.
48688+
1. If _queue_ is empty, then
48689+
1. Set _generator_.[[AsyncGeneratorState]] to ~completed~.
48690+
1. Set _done_ to *true*.
4868848691
1. Return ~unused~.
4868948692
</emu-alg>
4869048693
</emu-clause>

0 commit comments

Comments
 (0)