| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/annex-b-fns/global-existing-var-update.case |
| 3 |
// - src/annex-b-fns/global/switch-case.template |
| 4 |
/*--- |
| 5 |
description: Variable-scoped binding is updated following evaluation (Function declaration in the `case` clause of a `switch` statement in the global scope) |
| 6 |
esid: sec-web-compat-globaldeclarationinstantiation |
| 7 |
es6id: B.3.3.2 |
| 8 |
flags: [generated, noStrict] |
| 9 |
info: | |
| 10 |
B.3.3.2 Changes to GlobalDeclarationInstantiation |
| 11 |
[...] |
| 12 |
c. When the FunctionDeclaration f is evaluated, perform the following steps |
| 13 |
in place of the FunctionDeclaration Evaluation algorithm provided in |
| 14 |
14.1.21: |
| 15 |
|
| 16 |
i. Let genv be the running execution context's VariableEnvironment. |
| 17 |
ii. Let genvRec be genv's EnvironmentRecord. |
| 18 |
ii. Let benv be the running execution context's LexicalEnvironment. |
| 19 |
iv. Let benvRec be benv's EnvironmentRecord. |
| 20 |
v. Let fobj be ! benvRec.GetBindingValue(F, false). |
| 21 |
vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). |
| 22 |
vii. Return NormalCompletion(empty). |
| 23 |
---*/ |
| 24 |
|
| 25 |
switch (1) { |
| 26 |
case 1: |
| 27 |
function f() { return 'function declaration'; } |
| 28 |
} |
| 29 |
|
| 30 |
assert.sameValue(typeof f, 'function'); |
| 31 |
assert.sameValue(f(), 'function declaration'); |
| 32 |
|
| 33 |
var f = 123; |