scope-head-lex-open.js (1400B)
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 to serve as a temporal dead zone for 7 the statement's AssignmentExpresson 8 info: | 9 IterationStatement : for ( ForDeclaration of AssignmentExpression ) Statement 10 11 1. Let keyResult be the result of performing ? 12 ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, 13 AssignmentExpression, iterate). 14 [...] 15 16 13.7.5.12 Runtime Semantics: ForIn/OfHeadEvaluation 17 18 [...] 19 2. If TDZnames is not an empty List, then 20 a. Assert: TDZnames has no duplicate entries. 21 b. Let TDZ be NewDeclarativeEnvironment(oldEnv). 22 c. Let TDZEnvRec be TDZ's EnvironmentRecord. 23 d. For each string name in TDZnames, do 24 i. Perform ! TDZEnvRec.CreateMutableBinding(name, false). 25 e. Set the running execution context's LexicalEnvironment to TDZ. 26 3. Let exprRef be the result of evaluating expr. 27 [...] 28 features: [let] 29 ---*/ 30 31 let x = 'outside'; 32 var probeBefore = function() { return x; }; 33 var probeExpr; 34 35 for (let x in { i: probeExpr = function() { typeof x; }}) ; 36 37 assert.sameValue(probeBefore(), 'outside'); 38 assert.throws(ReferenceError, probeExpr); 39 40 reportCompare(0, 0);