array-rest-iter-thrw-close-err.js (2069B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/array-rest-iter-thrw-close-err.case 3 // - src/dstr-assignment/error/assignment-expr.template 4 /*--- 5 description: IteratorClose is called when reference evaluation produces a "throw" completion (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 : [ Elisionopt AssignmentRestElement ] 19 20 [...] 21 5. Let result be the result of performing 22 IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with 23 iteratorRecord as the argument 24 6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator, 25 result). 26 27 AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget 28 29 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an 30 ArrayLiteral, then 31 a. Let lref be the result of evaluating DestructuringAssignmentTarget. 32 b. ReturnIfAbrupt(lref). 33 34 ---*/ 35 var nextCount = 0; 36 var returnCount = 0; 37 var x; 38 function ReturnError() {} 39 var iterable = {}; 40 var iterator = { 41 next: function() { 42 nextCount += 1; 43 // Set an upper-bound to limit unnecessary iteration in non-conformant 44 // implementations 45 return { done: nextCount > 10 }; 46 }, 47 return: function() { 48 returnCount += 1; 49 50 // This value should be discarded. 51 throw new ReturnError(); 52 } 53 }; 54 var thrower = function() { 55 throw new Test262Error(); 56 }; 57 iterable[Symbol.iterator] = function() { 58 return iterator; 59 }; 60 61 62 assert.throws(Test262Error, function() { 63 0, [...{}[thrower()]] = iterable; 64 }); 65 66 assert.sameValue(nextCount, 0); 67 assert.sameValue(returnCount, 1); 68 69 reportCompare(0, 0);