Debian Codegraph @

js/src/tests/test262/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js

raw
1 // Copyright (C) 2018 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-web-compat-functiondeclarationinstantiation
6 description: >
7 Nested function declarations, the second declaration is not Annex-B applicable.
8 info: |
9 B.3.3.1 Changes to FunctionDeclarationInstantiation
10
11 1. If strict is false, then
12 a. For each FunctionDeclaration f that is directly contained in the
13 StatementList of a Block, CaseClause, or DefaultClause, do
14 i. Let F be StringValue of the BindingIdentifier of FunctionDeclaration f.
15 ii. If replacing the FunctionDeclaration f with a VariableStatement that
16 has F as a BindingIdentifier would not produce any Early Errors for
17 func and F is not an element of parameterNames, then
18 ...
19 flags: [noStrict]
20 ---*/
21
22 function g() {
23 // Create an outer block-statement.
24 {
25 // A lexically declared function declaration.
26 // This function is applicable for Annex-B semantics.
27 function f() { return 1; }
28
29 // An inner block-statement with another function declaration.
30 // This function is not applicable for Annex-B semantics, because
31 // replacing it with |var f| would result in a SyntaxError.
32 {
33 function f() { return 2; }
34 }
35 }
36
37 assert.sameValue(f(), 1);
38 }
39
40 g();
41
42 reportCompare(0, 0);