| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/annex-b-fns/func-skip-early-err-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.throws(ReferenceError, function() { |
| 31 |
f; |
| 32 |
}, 'An initialized binding is not created prior to evaluation'); |
| 33 |
assert.sameValue( |
| 34 |
typeof f, |
| 35 |
'undefined', |
| 36 |
'An uninitialized binding is not created prior to evaluation' |
| 37 |
); |
| 38 |
|
| 39 |
try { |
| 40 |
throw {}; |
| 41 |
} catch ({ f }) { |
| 42 |
|
| 43 |
switch (1) { |
| 44 |
case 1: |
| 45 |
function f() { } |
| 46 |
} |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
assert.throws(ReferenceError, function() { |
| 51 |
f; |
| 52 |
}, 'An initialized binding is not created following evaluation'); |
| 53 |
assert.sameValue( |
| 54 |
typeof f, |
| 55 |
'undefined', |
| 56 |
'An uninitialized binding is not created following evaluation' |
| 57 |
); |
| 58 |
}()); |