From 0fc1e8b38b31f2ed5fabe680de22c09e83b8afd0 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Wed, 5 Jan 2022 17:22:35 -0800 Subject: [PATCH] Fix GeneratorYield callsites to create an iter object --- spec.html | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index 7ba5639a9df..7bb444d5f1d 100644 --- a/spec.html +++ b/spec.html @@ -7167,7 +7167,7 @@

1. Let _closure_ be a new Abstract Closure with no parameters that captures _list_ and performs the following steps when called: 1. For each element _E_ of _list_, do - 1. Perform ? GeneratorYield(_E_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_E_, *false*)). 1. Return *undefined*. 1. Let _iterator_ be ! CreateIteratorFromClosure(_closure_, ~empty~, %IteratorPrototype%). 1. Return Record { [[Iterator]]: _iterator_, [[NextMethod]]: %GeneratorFunction.prototype.prototype.next%, [[Done]]: *false* }. @@ -34274,7 +34274,7 @@

String.prototype [ @@iterator ] ( )

1. Let _nextIndex_ be _position_ + _cp_.[[CodeUnitCount]]. 1. Let _resultString_ be the substring of _s_ from _position_ to _nextIndex_. 1. Set _position_ to _nextIndex_. - 1. Perform ? GeneratorYield(_resultString_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_resultString_, *false*)). 1. Return *undefined*. 1. Return ! CreateIteratorFromClosure(_closure_, *"%StringIteratorPrototype%"*, %StringIteratorPrototype%).
@@ -36541,14 +36541,14 @@

1. Let _match_ be ? RegExpExec(_R_, _S_). 1. If _match_ is *null*, return *undefined*. 1. If _global_ is *false*, then - 1. Perform ? GeneratorYield(_match_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_match_, *false*)). 1. Return *undefined*. 1. Let _matchStr_ be ? ToString(? Get(_match_, *"0"*)). 1. If _matchStr_ is the empty String, then 1. Let _thisIndex_ be ℝ(? ToLength(? Get(_R_, *"lastIndex"*))). 1. Let _nextIndex_ be ! AdvanceStringIndex(_S_, _thisIndex_, _fullUnicode_). 1. Perform ? Set(_R_, *"lastIndex"*, 𝔽(_nextIndex_), *true*). - 1. Perform ? GeneratorYield(_match_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_match_, *false*)). 1. Return ! CreateIteratorFromClosure(_closure_, *"%RegExpStringIteratorPrototype%"*, %RegExpStringIteratorPrototype%). @@ -37939,14 +37939,15 @@

1. Else, 1. Let _len_ be ? LengthOfArrayLike(_array_). 1. If _index_ ≥ _len_, return *undefined*. - 1. If _kind_ is ~key~, perform ? GeneratorYield(𝔽(_index_)). + 1. If _kind_ is ~key~, perform ? GeneratorYield(! CreateIterResultObject(𝔽(_index_), *false*)). 1. Else, 1. Let _elementKey_ be ! ToString(𝔽(_index_)). 1. Let _elementValue_ be ? Get(_array_, _elementKey_). - 1. If _kind_ is ~value~, perform ? GeneratorYield(_elementValue_). + 1. If _kind_ is ~value~, perform ? GeneratorYield(! CreateIterResultObject(_elementValue_, *false*)). 1. Else, 1. Assert: _kind_ is ~key+value~. - 1. Perform ? GeneratorYield(! CreateArrayFromList(« 𝔽(_index_), _elementValue_ »)). + 1. Let _result_ be ! CreateArrayFromList(« 𝔽(_index_), _elementValue_ »). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)). 1. Set _index_ to _index_ + 1. 1. Return ! CreateIteratorFromClosure(_closure_, *"%ArrayIteratorPrototype%"*, %ArrayIteratorPrototype%). @@ -39749,7 +39750,7 @@

1. Else, 1. Assert: _kind_ is ~key+value~. 1. Let _result_ be ! CreateArrayFromList(« _e_.[[Key]], _e_.[[Value]] »). - 1. Perform ? GeneratorYield(_result_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)). 1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield. 1. Set _numEntries_ to the number of elements of _entries_. 1. Return *undefined*. @@ -40034,10 +40035,11 @@

1. Set _index_ to _index_ + 1. 1. If _e_ is not ~empty~, then 1. If _kind_ is ~key+value~, then - 1. Perform ? GeneratorYield(! CreateArrayFromList(« _e_, _e_ »)). + 1. Let _result_ be ! CreateArrayFromList(« _e_, _e_ »). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_result_, *false*)). 1. Else, 1. Assert: _kind_ is ~value~. - 1. Perform ? GeneratorYield(_e_). + 1. Perform ? GeneratorYield(! CreateIterResultObject(_e_, *false*)). 1. NOTE: The number of elements in _entries_ may have changed while execution of this abstract operation was paused by Yield. 1. Set _numEntries_ to the number of elements of _entries_. 1. Return *undefined*.