func-block-decl-eval-func-init.js (1237B)
1 // This file was procedurally generated from the following sources: 2 // - src/annex-b-fns/eval-func-init.case 3 // - src/annex-b-fns/eval-func/direct-block.template 4 /*--- 5 description: Variable binding is initialized to `undefined` in outer scope (Block statement in eval code containing a function declaration) 6 esid: sec-web-compat-evaldeclarationinstantiation 7 flags: [generated, noStrict] 8 info: | 9 B.3.3.3 Changes to EvalDeclarationInstantiation 10 11 [...] 12 a. If declaredFunctionOrVarNames does not contain F, then 13 i. If varEnvRec is a global Environment Record, then 14 [...] 15 ii. Else, 16 i. Let bindingExists be varEnvRec.HasBinding(F). 17 ii. If bindingExists is false, then 18 i. Perform ! varEnvRec.CreateMutableBinding(F, true). 19 ii. Perform ! varEnvRec.InitializeBinding(F, undefined). 20 [...] 21 ---*/ 22 var init, changed; 23 24 (function() { 25 eval( 26 'init = f;\ 27 f = 123;\ 28 changed = f;{ function f() { } }' 29 ); 30 }()); 31 32 assert.sameValue(init, undefined, 'binding is initialized to `undefined`'); 33 assert.sameValue(changed, 123, 'binding is mutable'); 34 assert.throws(ReferenceError, function() { 35 f; 36 }, 'global binding is not created'); 37 38 reportCompare(0, 0);