|
| 1 | +// Copyright (C) 2026 Garham Lee. All rights reserved. |
| 2 | +// This code is governed by the BSD license found in the LICENSE file. |
| 3 | + |
| 4 | +/*--- |
| 5 | +esid: sec-runtime-semantics-bindinginitialization |
| 6 | +description: > |
| 7 | + IteratorStepValue throws when iteratorRecord.[[NextMethod]] is undefined. |
| 8 | +info: | |
| 9 | + Runtime Semantics: BindingInitialization (_value_, _environment_) |
| 10 | +
|
| 11 | + BindingPattern : ArrayBindingPattern |
| 12 | + 1. Let _iteratorRecord_ be ? GetIterator(_value_, ~sync~). |
| 13 | + 2. Let _result_ be Completion(IteratorBindingInitialization of |ArrayBindingPattern| with arguments _iteratorRecord_ and _environment_). |
| 14 | +
|
| 15 | + Runtime Semantics: IteratorBindingInitialization (_iteratorRecord_, _environment_) |
| 16 | +
|
| 17 | + BindingElement : BindingPattern Initializer? |
| 18 | + 2. If _iteratorRecord_.[[Done]] is *false*, then |
| 19 | + a. Let _next_ be ? IteratorStepValue(_iteratorRecord_). |
| 20 | +
|
| 21 | + IteratorStepValue (_iteratorRecord_) |
| 22 | + 1. Let _result_ be ? IteratorStep(_iteratorRecord_). |
| 23 | +
|
| 24 | + IteratorStep (_iteratorRecord_) |
| 25 | + 1. Let _result_ be ? IteratorNext(_iteratorRecord_). |
| 26 | +
|
| 27 | + IteratorNext (_iteratorRecord_, optional _value_) |
| 28 | + 1. If _value_ is not present, then |
| 29 | + a. Let _result_ be Completion(Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]])). |
| 30 | + 6. Return _result_. |
| 31 | +features: [destructuring-binding, async-functions, async-iteration, Symbol.iterator] |
| 32 | +---*/ |
| 33 | +assert.throws(TypeError, function () { |
| 34 | + var [[] = 1] = { [Symbol.iterator] : async function (x) {}}; |
| 35 | +}, "IteratorStepValue throws when iteratorRecord.[[NextMethod]] is undefined."); |
0 commit comments