| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/annex-b-fns/eval-func-existing-block-fn-update.case |
| 3 |
// - src/annex-b-fns/eval-func/direct-block.template |
| 4 |
/*--- |
| 5 |
description: Variable-scoped binding is updated (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 |
b. When the FunctionDeclaration f is evaluated, perform the following steps |
| 14 |
in place of the FunctionDeclaration Evaluation algorithm provided in |
| 15 |
14.1.21: |
| 16 |
i. Let genv be the running execution context's VariableEnvironment. |
| 17 |
ii. Let genvRec be genv's EnvironmentRecord. |
| 18 |
iii. 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 |
var updated; |
| 25 |
|
| 26 |
(function() { |
| 27 |
eval( |
| 28 |
'{\ |
| 29 |
function f() {\ |
| 30 |
return "first declaration";\ |
| 31 |
}\ |
| 32 |
}{ function f() { return "second declaration"; } }updated = f;' |
| 33 |
); |
| 34 |
}()); |
| 35 |
|
| 36 |
assert.sameValue(typeof updated, 'function'); |
| 37 |
assert.sameValue(updated(), 'second declaration'); |