Debian Codegraph @

js/src/tests/test262/language/eval-code/direct/var-env-func-init-multi.js

raw
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-evaldeclarationinstantiation
5 description: Precedence of final declaration when bindings are duplicated
6 info: |
7 [...]
8 8. For each d in varDeclarations, in reverse list order do
9 a. If d is neither a VariableDeclaration or a ForBinding, then
10 i. Assert: d is either a FunctionDeclaration or a
11 GeneratorDeclaration.
12 [...]
13 iv. If fn is not an element of declaredFunctionNames, then
14 [...]
15 3. Insert d as the first element of functionsToInitialize.
16 [...]
17 15. For each production f in functionsToInitialize, do
18 a. Let fn be the sole element of the BoundNames of f.
19 b. Let fo be the result of performing InstantiateFunctionObject for f
20 with argument lexEnv.
21 [...]
22 flags: [noStrict]
23 ---*/
24
25 var initial;
26
27 eval('initial = f; function f() { return "first"; } function f() { return "second"; }');
28
29 assert.sameValue(initial(), 'second', 'initial value');
30 assert.sameValue(f(), 'second', 'value following declaration evaluation');
31
32 reportCompare(0, 0);