scope-body-lex-close.js (1341B)
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 Removal of lexical environment for the initial 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 probeDecl, probeBody; 30 31 for ( 32 let [x, _ = probeDecl = function() { return x; }] 33 in 34 { i: 0 } 35 ) 36 probeBody = function() { return x; }; 37 38 assert.sameValue(probeDecl(), 'i', 'reference from ForDeclaration'); 39 assert.sameValue(probeBody(), 'i', 'reference from statement body'); 40 assert.sameValue(x, 'outside'); 41 42 reportCompare(0, 0);