tor-browser

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

script-decl-func-dups.js (1315B)


      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-globaldeclarationinstantiation
      5 es6id: 15.1.8
      6 description: >
      7    When multiple like-named function declarations exist, the final is assigned
      8    to the new binding.
      9 info: |
     10  [...]
     11  9. Let declaredFunctionNames be a new empty List.
     12  10. For each d in varDeclarations, in reverse list order do
     13      a. If d is neither a VariableDeclaration or a ForBinding, then
     14         i. Assert: d is either a FunctionDeclaration or a
     15            GeneratorDeclaration.
     16         ii. NOTE If there are multiple FunctionDeclarations for the same name,
     17             the last declaration is used.
     18         iii. Let fn be the sole element of the BoundNames of d.
     19         iv. If fn is not an element of declaredFunctionNames, then
     20             1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
     21             2. If fnDefinable is false, throw a TypeError exception.
     22             3. Append fn to declaredFunctionNames.
     23             4. Insert d as the first element of functionsToInitialize.
     24  [...]
     25 ---*/
     26 
     27 $262.evalScript(
     28  'function f() { return 1; }' +
     29  'function f() { return 2; }' +
     30  'function f() { return 3; }'
     31 );
     32 
     33 assert.sameValue(f(), 3);
     34 
     35 reportCompare(0, 0);