summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js
blob: c7e85de89aa8e33c6cd79d6e4627093504f364d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (C) 2018 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-web-compat-functiondeclarationinstantiation
description: >
  Nested function declarations, the second declaration is not Annex-B applicable.
info: |
  B.3.3.1 Changes to FunctionDeclarationInstantiation

  1. If strict is false, then
    a. For each FunctionDeclaration f that is directly contained in the
       StatementList of a Block, CaseClause, or DefaultClause, do
      i. Let F be StringValue of the BindingIdentifier of FunctionDeclaration f.
      ii. If replacing the FunctionDeclaration f with a VariableStatement that
          has F as a BindingIdentifier would not produce any Early Errors for
          func and F is not an element of parameterNames, then
       ...
flags: [noStrict]
---*/

function g() {
    // Create an outer block-statement.
    {
        // A lexically declared function declaration.
        // This function is applicable for Annex-B semantics.
        function f() { return 1; }

        // An inner block-statement with another function declaration.
        // This function is not applicable for Annex-B semantics, because
        // replacing it with |var f| would result in a SyntaxError.
        {
            function f() { return 2; }
        }
    }

    assert.sameValue(f(), 1);
}

g();

reportCompare(0, 0);