var-ary-ptrn-rest-id-iter-step-err.js (2082B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case 3 // - src/dstr-binding/error/for-var.template 4 /*--- 5 description: Error forwarding when IteratorStep returns an abrupt completion (for statement) 6 esid: sec-for-statement-runtime-semantics-labelledevaluation 7 features: [generators, destructuring-binding] 8 flags: [generated] 9 info: | 10 IterationStatement : 11 for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement 12 13 1. Let varDcl be the result of evaluating VariableDeclarationList. 14 [...] 15 16 13.3.2.4 Runtime Semantics: Evaluation 17 18 VariableDeclarationList : VariableDeclarationList , VariableDeclaration 19 20 1. Let next be the result of evaluating VariableDeclarationList. 21 2. ReturnIfAbrupt(next). 22 3. Return the result of evaluating VariableDeclaration. 23 24 VariableDeclaration : BindingPattern Initializer 25 26 1. Let rhs be the result of evaluating Initializer. 27 2. Let rval be GetValue(rhs). 28 3. ReturnIfAbrupt(rval). 29 4. Return the result of performing BindingInitialization for BindingPattern 30 passing rval and undefined as arguments. 31 32 13.3.3.6 Runtime Semantics: IteratorBindingInitialization 33 BindingRestElement : ... BindingIdentifier 34 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, 35 environment). 36 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, 37 a. If iteratorRecord.[[done]] is false, 38 i. Let next be IteratorStep(iteratorRecord.[[iterator]]). 39 ii. If next is an abrupt completion, set iteratorRecord.[[done]] to 40 true. 41 iii. ReturnIfAbrupt(next). 42 43 ---*/ 44 var first = 0; 45 var second = 0; 46 var iter = function*() { 47 first += 1; 48 throw new Test262Error(); 49 second += 1; 50 }(); 51 52 assert.throws(Test262Error, function() { 53 for (var [...x] = iter; iterCount < 1; ) { 54 return; 55 } 56 }); 57 58 iter.next(); 59 assert.sameValue(first, 1); 60 assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); 61 62 reportCompare(0, 0);