| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/annex-b-fns/func-no-skip-try.case |
| 3 |
// - src/annex-b-fns/func/switch-case.template |
| 4 |
/*--- |
| 5 |
description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Function declaration in the `case` clause of a `switch` statement in function scope) |
| 6 |
esid: sec-web-compat-functiondeclarationinstantiation |
| 7 |
es6id: B.3.3.1 |
| 8 |
flags: [generated, noStrict] |
| 9 |
info: | |
| 10 |
B.3.3.1 Changes to FunctionDeclarationInstantiation |
| 11 |
|
| 12 |
[...] |
| 13 |
2. If instantiatedVarNames does not contain F, then |
| 14 |
a. Perform ! varEnvRec.CreateMutableBinding(F, false). |
| 15 |
b. Perform varEnvRec.InitializeBinding(F, undefined). |
| 16 |
c. Append F to instantiatedVarNames. |
| 17 |
[...] |
| 18 |
|
| 19 |
B.3.5 VariableStatements in Catch Blocks |
| 20 |
|
| 21 |
[...] |
| 22 |
- It is a Syntax Error if any element of the BoundNames of CatchParameter |
| 23 |
also occurs in the VarDeclaredNames of Block unless CatchParameter is |
| 24 |
CatchParameter:BindingIdentifier and that element is only bound by a |
| 25 |
VariableStatement, the VariableDeclarationList of a for statement, or the |
| 26 |
ForBinding of a for-in statement. |
| 27 |
---*/ |
| 28 |
|
| 29 |
(function() { |
| 30 |
assert.sameValue( |
| 31 |
f, undefined, 'Initialized binding created prior to evaluation' |
| 32 |
); |
| 33 |
|
| 34 |
try { |
| 35 |
throw null; |
| 36 |
} catch (f) { |
| 37 |
|
| 38 |
switch (1) { |
| 39 |
case 1: |
| 40 |
function f() { return 123; } |
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
assert.sameValue( |
| 46 |
typeof f, |
| 47 |
'function', |
| 48 |
'binding value is updated following evaluation' |
| 49 |
); |
| 50 |
assert.sameValue(f(), 123); |
| 51 |
}()); |