Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-existing-global-update.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/eval-global-existing-global-update.case
3 // - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template
4 /*---
5 description: Variable-scoped binding is updated following evaluation (IfStatement with a declaration in both statement positions in eval code)
6 esid: sec-functiondeclarations-in-ifstatement-statement-clauses
7 es6id: B.3.3
8 flags: [generated, noStrict]
9 includes: [fnGlobalObject.js]
10 info: |
11 The following rules for IfStatement augment those in 13.6:
12
13 IfStatement[Yield, Return]:
14 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return]
15 if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield]
16 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield]
17 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield]
18
19
20 B.3.3.3 Changes to EvalDeclarationInstantiation
21
22 [...]
23 b. When the FunctionDeclaration f is evaluated, perform the following steps
24 in place of the FunctionDeclaration Evaluation algorithm provided in
25 14.1.21:
26 i. Let genv be the running execution context's VariableEnvironment.
27 ii. Let genvRec be genv's EnvironmentRecord.
28 iii. Let benv be the running execution context's LexicalEnvironment.
29 iv. Let benvRec be benv's EnvironmentRecord.
30 v. Let fobj be ! benvRec.GetBindingValue(F, false).
31 vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
32 vii. Return NormalCompletion(empty).
33
34 ---*/
35 Object.defineProperty(fnGlobalObject(), 'f', {
36 value: function() { return 'Another function'; },
37 enumerable: true,
38 writable: true,
39 configurable: false
40 });
41
42 eval(
43 'if (true) function f() { return "function declaration"; } else function _f() {}'
44 );
45
46 assert.sameValue(typeof f, 'function');
47 assert.sameValue(f(), 'function declaration');