| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-assignment/array-rest-iter-rtrn-close-null.case |
| 3 |
// - src/dstr-assignment/default/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 |
es6id: 13.3.2.4 |
| 8 |
features: [Symbol.iterator, generators, destructuring-binding] |
| 9 |
flags: [generated] |
| 10 |
info: | |
| 11 |
VariableDeclaration : BindingPattern Initializer |
| 12 |
|
| 13 |
1. Let rhs be the result of evaluating Initializer. |
| 14 |
2. Let rval be GetValue(rhs). |
| 15 |
3. ReturnIfAbrupt(rval). |
| 16 |
4. Return the result of performing BindingInitialization for |
| 17 |
BindingPattern passing rval and undefined as arguments. |
| 18 |
|
| 19 |
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ] |
| 20 |
|
| 21 |
[...] |
| 22 |
5. Let result be the result of performing |
| 23 |
IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with |
| 24 |
iteratorRecord as the argument |
| 25 |
6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, |
| 26 |
result). |
| 27 |
|
| 28 |
AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget |
| 29 |
|
| 30 |
1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an |
| 31 |
ArrayLiteral, then |
| 32 |
a. Let lref be the result of evaluating DestructuringAssignmentTarget. |
| 33 |
b. ReturnIfAbrupt(lref). |
| 34 |
|
| 35 |
7.4.6 IteratorClose( iterator, completion ) |
| 36 |
|
| 37 |
[...] |
| 38 |
6. Let innerResult be Call(return, iterator, « »). |
| 39 |
[...] |
| 40 |
|
| 41 |
7.4.6 IteratorClose( iterator, completion ) |
| 42 |
|
| 43 |
[...] |
| 44 |
6. Let innerResult be Call(return, iterator, « »). |
| 45 |
7. If completion.[[type]] is throw, return Completion(completion). |
| 46 |
8. If innerResult.[[type]] is throw, return Completion(innerResult). |
| 47 |
|
| 48 |
---*/ |
| 49 |
var iterable = {}; |
| 50 |
var iterator = { |
| 51 |
return: function() { |
| 52 |
return null; |
| 53 |
} |
| 54 |
}; |
| 55 |
var iter; |
| 56 |
iterable[Symbol.iterator] = function() { |
| 57 |
return iterator; |
| 58 |
}; |
| 59 |
|
| 60 |
function* g() { |
| 61 |
|
| 62 |
var result; |
| 63 |
var vals = iterable; |
| 64 |
|
| 65 |
result = [...{}[yield]] = vals; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
assert.sameValue(result, vals); |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
iter = g(); |
| 74 |
iter.next(); |
| 75 |
|
| 76 |
assert.throws(TypeError, function() { |
| 77 |
iter.return(); |
| 78 |
}); |