Debian Codegraph @

js/src/tests/test262/language/expressions/assignment/dstr/array-empty-iter-close-null.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-empty-iter-close-null.case
3 // - src/dstr-assignment/error/assignment-expr.template
4 /*---
5 description: IteratorClose throws a TypeError when `return` returns a non-Object value (AssignmentExpression)
6 esid: sec-variable-statement-runtime-semantics-evaluation
7 features: [Symbol.iterator, destructuring-binding]
8 flags: [generated]
9 info: |
10 VariableDeclaration : BindingPattern Initializer
11
12 1. Let rhs be the result of evaluating Initializer.
13 2. Let rval be GetValue(rhs).
14 3. ReturnIfAbrupt(rval).
15 4. Return the result of performing BindingInitialization for
16 BindingPattern passing rval and undefined as arguments.
17
18 ArrayAssignmentPattern : [ ]
19
20 1. Let iterator be GetIterator(value).
21 2. ReturnIfAbrupt(iterator).
22 3. Return IteratorClose(iterator, NormalCompletion(empty)).
23
24 7.4.6 IteratorClose( iterator, completion )
25
26 [...]
27 6. Let innerResult be Call(return, iterator, « »).
28 7. If completion.[[type]] is throw, return Completion(completion).
29 8. If innerResult.[[type]] is throw, return Completion(innerResult).
30 9. If Type(innerResult.[[value]]) is not Object, throw a TypeError
31 exception.
32
33 ---*/
34 var iterable = {};
35 var iterator = {
36 next: function() {
37 return { done: true };
38 },
39 return: function() {
40 return null;
41 }
42 };
43 iterable[Symbol.iterator] = function() {
44 return iterator;
45 };
46
47 assert.throws(TypeError, function() {
48 0, [] = iterable;
49 });
50
51 reportCompare(0, 0);