tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

scope-head-lex-close.js (1639B)


      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 to serve as a temporal dead zone for the
      7    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    4. Set the running execution context's LexicalEnvironment to oldEnv.
     28    [...]
     29 features: [let]
     30 ---*/
     31 
     32 let x = 'outside';
     33 var probeDecl, probeExpr, probeBody;
     34 
     35 for (
     36    let [x, _ = probeDecl = function() { return x; }]
     37    in
     38    { i: probeExpr = function() { typeof x; } }
     39  )
     40  probeBody = function() { return x; };
     41 
     42 assert.throws(ReferenceError, probeExpr);
     43 assert.sameValue(probeDecl(), 'i', 'reference from ForDeclaration');
     44 assert.sameValue(probeBody(), 'i', 'reference from statement body');
     45 
     46 reportCompare(0, 0);