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