tor-browser

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

scope-meth-paramsbody-var-close.js (1140B)


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