scope-body-lex-boundary.js (1280B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation 5 description: > 6 Creation of new lexical environment for each evaluation of the statement 7 body 8 info: | 9 IterationStatement : for ( ForDeclaration of AssignmentExpression ) Statement 10 11 [...] 12 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, 13 lexicalBinding, labelSet). 14 15 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation 16 17 [...] 18 5. Repeat 19 [...] 20 i. Let result be the result of evaluating stmt. 21 j. Set the running execution context's LexicalEnvironment to oldEnv. 22 k. If LoopContinues(result, labelSet) is false, return ? 23 IteratorClose(iterator, UpdateEmpty(result, V)). 24 l. If result.[[Value]] is not empty, let V be result.[[Value]]. 25 features: [let] 26 ---*/ 27 28 let x = 'outside'; 29 var probeFirst, probeSecond; 30 31 for (let x of ['first', 'second']) 32 if (!probeFirst) 33 probeFirst = function() { return x; }; 34 else 35 probeSecond = function() { return x; }; 36 37 assert.sameValue(probeFirst(), 'first'); 38 assert.sameValue(probeSecond(), 'second'); 39 40 reportCompare(0, 0);