| 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 |
es6id: B.3.3.3 |
| 8 |
flags: [generated, noStrict] |
| 9 |
info: | |
| 10 |
B.3.3.3 Changes to EvalDeclarationInstantiation |
| 11 |
|
| 12 |
[...] |
| 13 |
a. If declaredFunctionOrVarNames does not contain F, then |
| 14 |
i. If varEnvRec is a global Environment Record, then |
| 15 |
[...] |
| 16 |
ii. Else, |
| 17 |
i. Let bindingExists be varEnvRec.HasBinding(F). |
| 18 |
ii. If bindingExists is false, then |
| 19 |
i. Perform ! varEnvRec.CreateMutableBinding(F, true). |
| 20 |
ii. Perform ! varEnvRec.InitializeBinding(F, undefined). |
| 21 |
[...] |
| 22 |
---*/ |
| 23 |
var init, changed; |
| 24 |
|
| 25 |
(function() { |
| 26 |
eval( |
| 27 |
'init = f;\ |
| 28 |
f = 123;\ |
| 29 |
changed = f;{ function f() { } }' |
| 30 |
); |
| 31 |
}()); |
| 32 |
|
| 33 |
assert.sameValue(init, undefined, 'binding is initialized to `undefined`'); |
| 34 |
assert.sameValue(changed, 123, 'binding is mutable'); |
| 35 |
assert.throws(ReferenceError, function() { |
| 36 |
f; |
| 37 |
}, 'global binding is not created'); |