scope-head-var-none.js (1675B)
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: No variable environment is created for the statement "head" 6 info: | 7 [...] 8 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv). 9 3. Let loopEnvRec be loopEnv's EnvironmentRecord. 10 4. Let isConst be the result of performing IsConstantDeclaration of 11 LexicalDeclaration. 12 5. Let boundNames be the BoundNames of LexicalDeclaration. 13 6. For each element dn of boundNames do 14 a. If isConst is true, then 15 i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true). 16 b. Else, 17 i. Perform ! loopEnvRec.CreateMutableBinding(dn, false). 18 7. Set the running execution context's LexicalEnvironment to loopEnv. 19 [...] 20 12. Set the running execution context's LexicalEnvironment to oldEnv. 21 13. Return Completion(bodyResult). 22 flags: [noStrict] 23 ---*/ 24 25 var probeBefore = function() { return x; }; 26 var probeTest, probeIncr, probeBody; 27 var run = true; 28 29 for ( 30 var _ = eval('var x = 1;'); 31 run && (probeTest = function() { return x; }); 32 probeIncr = function() { return x; } 33 ) 34 probeBody = function() { return x; }, run = false; 35 36 var x = 2; 37 38 assert.sameValue(probeBefore(), 2, 'reference preceding statement'); 39 assert.sameValue(probeTest(), 2, 'reference from "test" position'); 40 assert.sameValue(probeBody(), 2, 'reference from statement body'); 41 assert.sameValue(probeIncr(), 2, 'reference from "increment" position'); 42 assert.sameValue(x, 2, 'reference following statement'); 43 44 reportCompare(0, 0);