scope-body-lex-boundary.js (1330B)
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-statement-runtime-semantics-labelledevaluation 5 description: > 6 Creation of new lexical environment for each evaluation of the statement 7 body 8 info: | 9 [...] 10 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second 11 Expression, Statement, perIterationLets, labelSet). 12 [...] 13 14 13.7.4.8 Runtime Semantics: ForBodyEvaluation 15 16 [...] 17 3. Repeat 18 [...] 19 b. Let result be the result of evaluating stmt. 20 [...] 21 e. Perform ? CreatePerIterationEnvironment(perIterationBindings). 22 [...] 23 24 13.7.4.9 Runtime Semantics: CreatePerIterationEnvironment 25 26 1. If perIterationBindings has any elements, then 27 [...] 28 e. Let thisIterationEnv be NewDeclarativeEnvironment(outer). 29 f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord. 30 features: [let] 31 ---*/ 32 33 var probeFirst; 34 var probeSecond = null; 35 36 for (let x = 'first'; probeSecond === null; x = 'second') 37 if (!probeFirst) 38 probeFirst = function() { return x; }; 39 else 40 probeSecond = function() { return x; }; 41 42 assert.sameValue(probeFirst(), 'first'); 43 assert.sameValue(probeSecond(), 'second'); 44 45 reportCompare(0, 0);