Skip to content

Commit f2bad00

Browse files
bakkotljharb
authored andcommitted
Normative: consuming helpers close receiver on argument validation failure (#3467)
1 parent 9552f29 commit f2bad00

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

spec.html

+25-10
Original file line numberDiff line numberDiff line change
@@ -47391,8 +47391,11 @@ <h1>Iterator.prototype.every ( _predicate_ )</h1>
4739147391
<emu-alg>
4739247392
1. Let _O_ be the *this* value.
4739347393
1. If _O_ is not an Object, throw a *TypeError* exception.
47394-
1. If IsCallable(_predicate_) is *false*, throw a *TypeError* exception.
47395-
1. Let _iterated_ be ? GetIteratorDirect(_O_).
47394+
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
47395+
1. If IsCallable(_predicate_) is *false*, then
47396+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
47397+
1. Return ? IteratorClose(_iterated_, _error_).
47398+
1. Set _iterated_ to ? GetIteratorDirect(_O_).
4739647399
1. Let _counter_ be 0.
4739747400
1. Repeat,
4739847401
1. Let _value_ be ? IteratorStepValue(_iterated_).
@@ -47438,8 +47441,11 @@ <h1>Iterator.prototype.find ( _predicate_ )</h1>
4743847441
<emu-alg>
4743947442
1. Let _O_ be the *this* value.
4744047443
1. If _O_ is not an Object, throw a *TypeError* exception.
47441-
1. If IsCallable(_predicate_) is *false*, throw a *TypeError* exception.
47442-
1. Let _iterated_ be ? GetIteratorDirect(_O_).
47444+
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
47445+
1. If IsCallable(_predicate_) is *false*, then
47446+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
47447+
1. Return ? IteratorClose(_iterated_, _error_).
47448+
1. Set _iterated_ to ? GetIteratorDirect(_O_).
4744347449
1. Let _counter_ be 0.
4744447450
1. Repeat,
4744547451
1. Let _value_ be ? IteratorStepValue(_iterated_).
@@ -47496,8 +47502,11 @@ <h1>Iterator.prototype.forEach ( _procedure_ )</h1>
4749647502
<emu-alg>
4749747503
1. Let _O_ be the *this* value.
4749847504
1. If _O_ is not an Object, throw a *TypeError* exception.
47499-
1. If IsCallable(_procedure_) is *false*, throw a *TypeError* exception.
47500-
1. Let _iterated_ be ? GetIteratorDirect(_O_).
47505+
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
47506+
1. If IsCallable(_procedure_) is *false*, then
47507+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
47508+
1. Return ? IteratorClose(_iterated_, _error_).
47509+
1. Set _iterated_ to ? GetIteratorDirect(_O_).
4750147510
1. Let _counter_ be 0.
4750247511
1. Repeat,
4750347512
1. Let _value_ be ? IteratorStepValue(_iterated_).
@@ -47541,8 +47550,11 @@ <h1>Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )</h1>
4754147550
<emu-alg>
4754247551
1. Let _O_ be the *this* value.
4754347552
1. If _O_ is not an Object, throw a *TypeError* exception.
47544-
1. If IsCallable(_reducer_) is *false*, throw a *TypeError* exception.
47545-
1. Let _iterated_ be ? GetIteratorDirect(_O_).
47553+
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
47554+
1. If IsCallable(_reducer_) is *false*, then
47555+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
47556+
1. Return ? IteratorClose(_iterated_, _error_).
47557+
1. Set _iterated_ to ? GetIteratorDirect(_O_).
4754647558
1. If _initialValue_ is not present, then
4754747559
1. Let _accumulator_ be ? IteratorStepValue(_iterated_).
4754847560
1. If _accumulator_ is ~done~, throw a *TypeError* exception.
@@ -47566,8 +47578,11 @@ <h1>Iterator.prototype.some ( _predicate_ )</h1>
4756647578
<emu-alg>
4756747579
1. Let _O_ be the *this* value.
4756847580
1. If _O_ is not an Object, throw a *TypeError* exception.
47569-
1. If IsCallable(_predicate_) is *false*, throw a *TypeError* exception.
47570-
1. Let _iterated_ be ? GetIteratorDirect(_O_).
47581+
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
47582+
1. If IsCallable(_predicate_) is *false*, then
47583+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
47584+
1. Return ? IteratorClose(_iterated_, _error_).
47585+
1. Set _iterated_ to ? GetIteratorDirect(_O_).
4757147586
1. Let _counter_ be 0.
4757247587
1. Repeat,
4757347588
1. Let _value_ be ? IteratorStepValue(_iterated_).

0 commit comments

Comments
 (0)