tor-browser

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

scope-setter-paramsbody-var-open.js (1191B)


      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-functiondeclarationinstantiation
      5 description: >
      6    Creation of new variable environment for the function body (as distinct from
      7    that for the function's parameters)
      8 info: |
      9    [...]
     10    26. If hasParameterExpressions is false, then
     11        [...]
     12    27. Else,
     13        a. NOTE A separate Environment Record is needed to ensure that closures
     14           created by expressions in the formal parameter list do not have
     15           visibility of declarations in the function body.
     16        b. Let varEnv be NewDeclarativeEnvironment(env).
     17        c. Let varEnvRec be varEnv's EnvironmentRecord.
     18        d. Set the VariableEnvironment of calleeContext to varEnv.
     19        e. Let instantiatedVarNames be a new empty List.
     20        [...]
     21 ---*/
     22 
     23 var x = 'outside';
     24 var probeParams, probeBody;
     25 
     26 ({
     27  set a(_ = probeParams = function() { return x; }) {
     28    var x = 'inside';
     29    probeBody = function() { return x; };
     30  }
     31 }.a = undefined);
     32 
     33 assert.sameValue(probeParams(), 'outside');
     34 assert.sameValue(probeBody(), 'inside');
     35 
     36 reportCompare(0, 0);