switch-dflt-global-skip-early-err-block.js (1268B)
1 // This file was procedurally generated from the following sources: 2 // - src/annex-b-fns/global-skip-early-err-block.case 3 // - src/annex-b-fns/global/switch-dflt.template 4 /*--- 5 description: Extension not observed when creation of variable binding would produce an early error (Block statement) (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 [...] 12 b. If replacing the FunctionDeclaration f with a VariableStatement that has 13 F as a BindingIdentifier would not produce any Early Errors for script, 14 then 15 [...] 16 ---*/ 17 assert.throws(ReferenceError, function() { 18 f; 19 }, 'An initialized binding is not created prior to evaluation'); 20 assert.sameValue( 21 typeof f, 22 'undefined', 23 'An uninitialized binding is not created prior to evaluation' 24 ); 25 26 { 27 let f = 123; 28 29 switch (1) { 30 default: 31 function f() { } 32 } 33 34 } 35 36 assert.throws(ReferenceError, function() { 37 f; 38 }, 'An initialized binding is not created following evaluation'); 39 assert.sameValue( 40 typeof f, 41 'undefined', 42 'An uninitialized binding is not created following evaluation' 43 ); 44 45 reportCompare(0, 0);