tor-browser

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

switch-case-func-existing-block-fn-update.js (1384B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/annex-b-fns/func-existing-block-fn-update.case
      3 // - src/annex-b-fns/func/switch-case.template
      4 /*---
      5 description: Variable-scoped binding is updated (Function declaration in the `case` clause of a `switch` statement in function scope)
      6 esid: sec-web-compat-functiondeclarationinstantiation
      7 flags: [generated, noStrict]
      8 info: |
      9    B.3.3.1 Changes to FunctionDeclarationInstantiation
     10 
     11    [...]
     12    3. When the FunctionDeclaration f is evaluated, perform the following steps
     13       in place of the FunctionDeclaration Evaluation algorithm provided in
     14       14.1.21:
     15       a. Let fenv be the running execution context's VariableEnvironment.
     16       b. Let fenvRec be fenv's EnvironmentRecord.
     17       c. Let benv be the running execution context's LexicalEnvironment.
     18       d. Let benvRec be benv's EnvironmentRecord.
     19       e. Let fobj be ! benvRec.GetBindingValue(F, false).
     20       f. Perform ! fenvRec.SetMutableBinding(F, fobj, false).
     21       g. Return NormalCompletion(empty). 
     22 ---*/
     23 var updated;
     24 
     25 (function() {
     26  {
     27    function f() {
     28      return 'first declaration';
     29    }
     30  }
     31 
     32  switch (1) {
     33    case 1:
     34      function f() { return 'second declaration'; }
     35  }
     36 
     37  updated = f;
     38 }());
     39 
     40 assert.sameValue(typeof updated, 'function');
     41 assert.sameValue(updated(), 'second declaration');
     42 
     43 reportCompare(0, 0);