diff --git a/src/annex-b-fns/eval-func-no-skip-try.case b/src/annex-b-fns/eval-func-no-skip-try.case new file mode 100644 index 0000000000000000000000000000000000000000..b27076a6bb52609641a6581c1434490515824d5a --- /dev/null +++ b/src/annex-b-fns/eval-func-no-skip-try.case @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { +//- body +return 123; +//- after +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/src/annex-b-fns/eval-func-skip-early-err-block.case b/src/annex-b-fns/eval-func-skip-early-err-block.case new file mode 100644 index 0000000000000000000000000000000000000000..a44a40e87565af06cc9e8f21357b0c7659e673df --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-block.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (Block statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-func-skip-early-err-for-in.case b/src/annex-b-fns/eval-func-skip-early-err-for-in.case new file mode 100644 index 0000000000000000000000000000000000000000..42466efd425ebc1786168610ef7e9c27937ac94b --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-for-in.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-func-skip-early-err-for-of.case b/src/annex-b-fns/eval-func-skip-early-err-for-of.case new file mode 100644 index 0000000000000000000000000000000000000000..4d875d57b160c3df6635e5f1338be4baf4394705 --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-for-of.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-func-skip-early-err-for.case b/src/annex-b-fns/eval-func-skip-early-err-for.case new file mode 100644 index 0000000000000000000000000000000000000000..89c136f155aed3159178094de87d633057de9a28 --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-for.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { +//- after + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-func-skip-early-err-switch.case b/src/annex-b-fns/eval-func-skip-early-err-switch.case new file mode 100644 index 0000000000000000000000000000000000000000..5054d1455f4c4ef4faabae533fdaec5ea65506e4 --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-switch.case @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (switch statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-func-skip-early-err-try.case b/src/annex-b-fns/eval-func-skip-early-err-try.case new file mode 100644 index 0000000000000000000000000000000000000000..976317bfa3252a9ed8a6e2655870e31c7efb4d8c --- /dev/null +++ b/src/annex-b-fns/eval-func-skip-early-err-try.case @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is not observed when creation of variable binding would produce an + early error (try statement) +template: eval-func +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-no-skip-try.case b/src/annex-b-fns/eval-global-no-skip-try.case new file mode 100644 index 0000000000000000000000000000000000000000..fe04f27b8e20958049aadbf82a8a430b7f6ea2e9 --- /dev/null +++ b/src/annex-b-fns/eval-global-no-skip-try.case @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { +//- body +return 123; +//- after +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/src/annex-b-fns/eval-global-skip-early-err-block.case b/src/annex-b-fns/eval-global-skip-early-err-block.case new file mode 100644 index 0000000000000000000000000000000000000000..726c93250425a157a62b85fd196dbd193bdd99bb --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-block.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (Block statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); +//- before +{ +let f = 123; +//- after +} +//- teardown +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-skip-early-err-for-in.case b/src/annex-b-fns/eval-global-skip-early-err-for-in.case new file mode 100644 index 0000000000000000000000000000000000000000..1e9a6d5847b39ab54ee327be55f895f4c96d05af --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-for-in.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); +//- before +for (let f in { key: 0 }) { +//- after +} +//- teardown +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-skip-early-err-for-of.case b/src/annex-b-fns/eval-global-skip-early-err-for-of.case new file mode 100644 index 0000000000000000000000000000000000000000..fa093720736d99084e765eb4c2c95b99c513c292 --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-for-of.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); +//- before +for (let f of [0]) { +//- after +} +//- teardown +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-skip-early-err-for.case b/src/annex-b-fns/eval-global-skip-early-err-for.case new file mode 100644 index 0000000000000000000000000000000000000000..e2fc6fdfa917f7f7bd64c1b5ebd4b0804025023c --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-for.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); +//- before +for (let f; ; ) { +//- after + break; +} +//- teardown +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-skip-early-err-switch.case b/src/annex-b-fns/eval-global-skip-early-err-switch.case new file mode 100644 index 0000000000000000000000000000000000000000..46b5d1ead980e9dd7fed896d144ca909a500aeaf --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-switch.case @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (switch statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); +//- before +switch (0) { + default: + let f; +//- after +} +//- teardown +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/eval-global-skip-early-err-try.case b/src/annex-b-fns/eval-global-skip-early-err-try.case new file mode 100644 index 0000000000000000000000000000000000000000..47332bc708e6c85243aea0878785a6dedebbd2f7 --- /dev/null +++ b/src/annex-b-fns/eval-global-skip-early-err-try.case @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is not observed when creation of variable binding would produce an + early error (try statement) +template: eval-global +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-no-skip-try.case b/src/annex-b-fns/func-no-skip-try.case new file mode 100644 index 0000000000000000000000000000000000000000..d46944a084ada94979f5ef89c9865b7427fb2e51 --- /dev/null +++ b/src/annex-b-fns/func-no-skip-try.case @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { +//- body +return 123; +//- after +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/src/annex-b-fns/func-skip-early-err-block.case b/src/annex-b-fns/func-skip-early-err-block.case new file mode 100644 index 0000000000000000000000000000000000000000..5dc064e73317f3ab348538dbe64da91dff34cfd9 --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-block.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (Block statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-skip-early-err-for-in.case b/src/annex-b-fns/func-skip-early-err-for-in.case new file mode 100644 index 0000000000000000000000000000000000000000..980339763ff34ace2ab35c41dd4e135d82349cf5 --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-for-in.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-skip-early-err-for-of.case b/src/annex-b-fns/func-skip-early-err-for-of.case new file mode 100644 index 0000000000000000000000000000000000000000..b06e3fce17e87321cc748364aedb3b00de6b3d3b --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-for-of.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-skip-early-err-for.case b/src/annex-b-fns/func-skip-early-err-for.case new file mode 100644 index 0000000000000000000000000000000000000000..6cae068a8b2d86937b8676e98c5d99062e4ef155 --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-for.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { +//- after + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-skip-early-err-switch.case b/src/annex-b-fns/func-skip-early-err-switch.case new file mode 100644 index 0000000000000000000000000000000000000000..3ba69334ce7a43914b2d7c4a7c11b06f5f28accf --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-switch.case @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (switch statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/func-skip-early-err-try.case b/src/annex-b-fns/func-skip-early-err-try.case new file mode 100644 index 0000000000000000000000000000000000000000..9631a45a53cd6a4b2aa4e259459a3823e15ac548 --- /dev/null +++ b/src/annex-b-fns/func-skip-early-err-try.case @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: func +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- before +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { +//- after +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-no-skip-try.case b/src/annex-b-fns/global-no-skip-try.case new file mode 100644 index 0000000000000000000000000000000000000000..71c8400aa0e6fcb98215cc1586d8ebc8ced87778 --- /dev/null +++ b/src/annex-b-fns/global-no-skip-try.case @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- setup +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { +//- body +return 123; +//- teardown +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/src/annex-b-fns/global-skip-early-err-block.case b/src/annex-b-fns/global-skip-early-err-block.case new file mode 100644 index 0000000000000000000000000000000000000000..2f7d97b54d258a2425ff102d96d9fd85852a455d --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-block.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (Block statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; +//- teardown +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-skip-early-err-for-in.case b/src/annex-b-fns/global-skip-early-err-for-in.case new file mode 100644 index 0000000000000000000000000000000000000000..0993afb73115b47fe05dcb31b2a0894bc7cc718e --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-for-in.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { +//- teardown +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-skip-early-err-for-of.case b/src/annex-b-fns/global-skip-early-err-for-of.case new file mode 100644 index 0000000000000000000000000000000000000000..567644e743d0943ca5eebefdb0b36a33501d05f2 --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-for-of.case @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for-of statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { +//- teardown +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-skip-early-err-for.case b/src/annex-b-fns/global-skip-early-err-for.case new file mode 100644 index 0000000000000000000000000000000000000000..9e1cc44fdf30ccefb12e7b67d5eee9998acfe844 --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-for.case @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (for statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { +//- teardown + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-skip-early-err-switch.case b/src/annex-b-fns/global-skip-early-err-switch.case new file mode 100644 index 0000000000000000000000000000000000000000..c5b430d9e9951c78d188edeb433160950435a467 --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-switch.case @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension not observed when creation of variable binding would produce an + early error (switch statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; +//- teardown +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/src/annex-b-fns/global-skip-early-err-try.case b/src/annex-b-fns/global-skip-early-err-try.case new file mode 100644 index 0000000000000000000000000000000000000000..45058461d7eed382c567e18341bf1917a444999f --- /dev/null +++ b/src/annex-b-fns/global-skip-early-err-try.case @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + Extension is observed when creation of variable binding would not produce an + early error (try statement) +template: global +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +//- setup +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { +//- teardown +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-block-scoping.js index d8533d50fb3faf36cb2f55b11903f9c97ad46626..4a93e0825b3621b1eb464e42f353c0a58e61db29 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Block statement in eval code con esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-no-init.js index 320d44ef4a39c4ed43378aaccd03bdabb9a0d1be..6ff8750f30ffb3e85b7842b24f2fb23f8814a770 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-update.js index 650c0ac8ccf9d144fb5cf1f745b2452a8cf33a92..4d40ddfd5057e520ea937bfb85c3892629e32466 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Block statement in eval code co esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-no-init.js index ffc1d300dfb8d7408a7c86fa1c7bcd8961972fb6..c8f3cb4babc8e818aa1cdcd3b002dd548e71f219 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-update.js index ae1798afc68481fca8a9007ba08208ce686a115b..8bd5b9024c3a7bc4c4690dee13295f5a735dfa73 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-no-init.js index 2a3f6da9785f8365a42684408b4bbcba2d26555f..65bf8da2eaf3bcec07fccf006df93f6c7ffaba21 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-update.js index 630a1f1d7c23ab96b436d9621e0af323b8228c7e..9183b04811244f501dfee892f499ae066a2ad67a 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-init.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-init.js index b3c52cda9d7b96f30e0337ae79248357c13d9db2..d14c3b0e398fd208572c7bf5684301838910f970 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Bloc esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-param.js index 4060724dc5ef4742a19d9a4b173cb6f8bfd749b6..c633517471907c36ed975f97c50a8935a4afedef 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-param.js @@ -6,9 +6,9 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..b8f2cfe235abe8863d0428c4f75a2404bfbab231 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-no-skip-try.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {{ function f() { return 123; } }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..9e53d7cd327bc17d82fcc86e1b5aa9cd3cd30e02 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..6ac27ca34e8cb3ab43e911ad495ef9aaf09cdbc4 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-in.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..7d585a7ed8463882b1cc939c9240b8350c9b886d --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-of.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..a98762f861cca498ec3f1f0faeaf2b327ed871b9 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {{ function f() { } }break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..d53376e72916fe436da78fba3ba44e31fa6c4581 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-switch.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..9788891a0fb9dc9b948367dbe06001d52a861468 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-block.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err.js index 10ea83f5569ffe3d87ea3c53de0b9d3fac0ee426..aa2bce5c5554e2a7a49a586cfd59157fc78f8b90 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-update.js b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-update.js index ee7845971298be5589abe58c50c8ed823dfceb80..aa8216214cdec780283e0c705336f30435cb82c6 100644 --- a/test/annexB/language/eval-code/direct/func-block-decl-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-block-decl-eval-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Block state esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-block-scoping.js index 10b3d18eeae7f642b9b9ed5ba7a02616203461da..7bb0b5735b0745cbc64b0502ef0f4fde38ce02aa 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-no-init.js index 1c4b16339f3eb71fae79250705d97f984c5a424e..e0599921edd44092a7c38e5373e26d7780972515 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-update.js index 3420e79c65c17e5b90222c56c17e776a80094641..1b4b1ee9993a48e72048b618fc7319d0cf411e53 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-no-init.js index 35c10ae5b50a3a5de5356e72d53afe6150f41f16..a4c58f0cefe3ed64d1fc760f11d14cbf8f45a8f7 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-update.js index 7d60a2c9e5d66430d127dd3620e55ea12f7c84f8..c9ef386a62a299a6d0cbfc15b640140341dd8981 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-no-init.js index 76135262bf80545eaf11d11d5782551a24ed029d..5d145b06192abcff2fcdb8ac372991da3556f03e 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-update.js index 4348c6f6f72720ba61e2e1c873f46be4db1a5af8..b67d7a1394406aed38d357106fdd2369a141b9a0 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-init.js index 7e8f99f3a6696fe9f48b0c3b870ce735e3bdd254..2d3c6068dd47e11be66f0c5562bfadaafcc58260 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-param.js index 19c36fb02134f17052c857e7cc078a8e02aa9f9c..d693f0caabd0a5b9d427b20ff35b60f3e0afe86a 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-param.js @@ -6,18 +6,18 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..5a6029524ce63cec5e075657c932ae02a97ad3d3 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-no-skip-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else function _f() {}}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..b317b8b3274fff28e04272cdee154e934ab61209 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-block.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..cf10d13dfca6f87e03dd5db7d6ec0ad4a5800825 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-in.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f4e063cc0ff70288fe6badfeb3f1e6e88442f4ff --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for-of.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..092b5ef7a1f397968482e4c5f5b4995a0b13d416 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-for.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {if (true) function f() { } else function _f() {}break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..61bbf03be1dfc5f4bdf28bb14d6f2d9e8d40fbdd --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-switch.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..0db003af7c2aebe9eaf02069cc96db8d2484a71b --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err-try.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-a.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err.js index a6e83975f9138ff3ec5ce349b5d39957708e029f..450797fa9ab076a2dfcfebb7f6aa6ffc07103829 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-update.js index fc5e5bb957a23155f688cf97b3eaa998035c7381..9b9d6187610e65afe26cac6bcd243f6381f3f657 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-a-eval-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-block-scoping.js index 72b38479670a7954edcb4b4208cbb1601f782b7f..5e36e28d115fb9f9cdadc209f161af723596b396 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-no-init.js index a85a22904404d8019f3e2c12ea8148baaab4bcd3..59f20d74d65e09f36fcb1c7ebd5aab1c10fb77b8 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-update.js index 7a97f23e65b558f015d20f2a3aaab22fb86e256f..a0cc11d0b3920b7e3010e51d6c708055a619500e 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-no-init.js index 0d285f26d4e3b65c751160d29ee06925a2347051..1c7ed613e8d3b40f6b8755dcabd4cd418c4a2f93 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-update.js index 5679c966b3c4c5d3bc10c1578ecf662799c034cc..595c0fe846f5a047e07f291d1544cf4726adfa4c 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-no-init.js index d5ace969354584c24727bdf61ba3058ffab7cc8b..cbf8314733883336bf439b3f16e11e75e0600f1e 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-update.js index ca15456d4f6ea7900d049dcd7250f5feaabc9b57..6e7b2293144f917ce6fc61cd93f07af46decdfa7 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-init.js index ec92dbc0f88a8a98982a1346f1ec3d46700e514a..d6d3895f91459dd5e387005986682055b478d168 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-param.js index 6f73881e40bb1ac9202336263dd0979f2f9c59ee..efff4672d94073eae824a360174e1c438a71741d 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-param.js @@ -6,18 +6,18 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..1ccab1e3af541432787d0098ac054ce6dde809ba --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-no-skip-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) function _f() {} else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..d68fc9fd601ef976e62b70605fe6a024b1cbb3c4 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-block.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..9bc2db66d6169fbcaea70c1d6d06626254e3839d --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-in.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..3c70bc297607842a89e3bff44f0c13c59e4b8110 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for-of.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..01e119125289ed64472bd77b88d5d5b81d91edec --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-for.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {if (false) function _f() {} else function f() { }break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..2cbb0182e21733b7b0c3a43cec275efaaffa286b --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-switch.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..71816738d93d5330f4f939d2df4398c53895ac2e --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err-try.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-decl-b.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err.js index 8196747e8266b2e4714fb53b3ab75e50ef60bbcb..bc8b712d3ad14ee81d932540dcc9880fa36a59fd 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-update.js index d4de052d62a16a1d2e647f96baf126a5e5fb7c9c..a337ccc63bca56e92539afe3a42b41d66df347cb 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-decl-b-eval-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-block-scoping.js index ece6a2f44a89e43492ee8ce10feeabc9bb22052c..1651d44a5c69c8b89b7a747a416be5ff765d4f13 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-no-init.js index fb6fd8fa55926c3f5c1cf373327081240dad4bdd..4f6223a0097025be380fb90eab80dea5e82b6967 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-update.js index ec377af61a951becec5ec0cd830b9685b9c78f56..f5f75eed91093574e50f78d2b23888309dd6ec81 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-no-init.js index 020c5de1ecd3eb8d72f2c0b2c8cc796f55199cd9..dc3ede644b619f103101ff03aebc37fa2c48a3c0 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-update.js index ed999ecc42e2e72150518551ba92bceacdb3d360..ea9d1ec4d4d9154e3f4a83307866aeefc22d3b9e 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-no-init.js index 77d5efffa630b537515788e94ae463f6bcbc3fa4..fa8f76cba796122966694dfbf9744a43bb1da1e3 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-update.js index 4ad6703fbd278433885cef42c6ecbeb105d1294e..eb922fc71cc6a6d0addebb9ce1479edde6ae18c6 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-init.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-init.js index cd73b1032274e02440f11570bb4ee76669999c06..6df813a3facbfa4e98792d7db61ed538e8552fb7 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-param.js index 36d39bc45ca0125b8c3e38d917e4222aa2b84ae2..17fe97e41144cc2b2a220d74aebaa470d1f89b03 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-param.js @@ -6,18 +6,18 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..cbd988ce28ef2bf1b6eb73dfab9342f4c82fd36c --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-no-skip-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else ;}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..c25c3ab475a78a334fd9a4d0fa2e12ba29334c0c --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-block.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..5e98627aa4d78b59d4812b226242536e3bef42f4 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-in.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f09656effe6570f3b40f8e89fc3e97a3984a9529 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for-of.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..ae1d6f5a362c406d9db34da999b9385eef2fe3a6 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-for.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {if (true) function f() { } else ;break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..870d39b0f2a0f84c02f4f9304538920c59b5565e --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-switch.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..b6e0886c7d390e04e127ca457769253a0ccc2c6c --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err-try.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-else-stmt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err.js index c445a5b6ef0c2795dc4a1ac630bb2abce9e7c727..dcc3e12509a64833fcd5808f37ed51bd0229d8b3 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-update.js b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-update.js index fc98ed89e5da45227ccf6c38a63bfdf9b4017275..ef257a963f7181c54c109e8babdf2511f42cfd07 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-else-stmt-eval-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-block-scoping.js index 00a50db1af4f56b8ca249ad778ffcbd4455d7cd9..36e26b26916a74a9077f66c06ce1aeaf9b0035f5 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement without an else clau esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-no-init.js index 1d510f8e2073017fb08803310ac6570dc57fc1eb..93a97011ba2cb1d5b0c30ee36946baec4b41702b 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-update.js index 50fdf16f67f38ee5f92fa209bbd60cd62b74fb2c..2351c4e4c5a12c5ab4180eee34061350e828e4b1 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement without an else cla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-no-init.js index 6ce5c0ee2bbb07f10a69ea5c88b5c68570a01ab5..738aad4e219e471b1f64b5ba9c156da571daa295 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-update.js index 2a6d761bbcdcc821990ad0a6d4ceedcfe9c2bc19..7372fc1fcab15ba54a09745613e56c50dba5b047 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-no-init.js index 98d7bf6b37d8bc26d558c5c977fca4531c9da330..9d0b9ba196f737010f1edd115c024f26065b6672 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-update.js index 367d91db54c27db933b4b676a1bd2d9074b8f294..037aaae6d72e6b0e98907749800fd604db2604c1 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-init.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-init.js index 9afcd6ceeb47f87ea183dea0f12a546a65a6f2e7..4e390b67ea7dccf7c651de3ca70e0ed2f88484d8 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-param.js index d6fbba2bfc2e71272d41564be305700fb8904add..ff27d9c604d45c6d9078a306f1e59256e776505e 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-param.js @@ -6,18 +6,18 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..c43e6e3a039a4baa51a58ddfa0de3a642a38fc94 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-no-skip-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..463237d72760104797871d33f09517553a21d07a --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-block.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..ce0fc0ace008684b89a2f23215e31da344fa5a39 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-in.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..9388c3cac98e3c96b4cbd58c0bb246fb26f5fa17 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for-of.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..55166eaf46dd27bfeef5949f263c54f488ef8e5e --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-for.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {if (true) function f() { }break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..109ec5441ed827d05900fb36f57201a9a1be518c --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-switch.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..b3dc095d31307aaab1094e26fea5c594b928919d --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err-try.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-if-decl-no-else.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err.js index 14fbd527b4f9403eae44a0f44f0e23900e0f7134..9940f43d43f1101ceb7429f5f29456e3c1a705f2 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-update.js b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-update.js index 34f3a751858aabb0347a121751eb974c976a5a3f..15f3fccd8ce8de9db1506c718f0d7a1441cbf52f 100644 --- a/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-if-decl-no-else-eval-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-block-scoping.js index 3cd18b4758e069751a6ace8d4d21d91e7fb48dfa..a5eac52f8cfc5d0e8efccc1295e98faf772769f7 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-no-init.js index ffe7aa17631cebb1405bb685ceadeb235cd21359..78b7e72e31907c6600e2f52a2181804051a878d3 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-update.js index 1ae723dcec17e6ae8184ceb2ae24f319dc5edac2..179f1ffed40d8187e30099532f11432053f2fff0 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-no-init.js index 8be95240ae886aa0b9e14938b4250276ba118d42..79ccb3c18b0e89a1314cee120ce1d9e1d6d0a86a 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-update.js index 3e5610c9ecef2a076184c9f9d664a1c1a839b54d..06513a992bba0e200384b91870101b296a5dcac8 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-no-init.js index b7bd73a9baa7ebb9d415267f31c083bba9d8da23..69f9c2950a2311bd1c6dad42e75c173e82426cc5 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-update.js index 18467f503101d9d8b6de736922c15079c4d3f4da..5b04cc86b1b8da5de571e8be8dc7cb31134713ad 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-init.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-init.js index c84ffef899cef89075e988da17e176c32c80e679..4a732afab68984c592447c7b5c980b51620adfd9 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-param.js index 90e4b58075afb0f8062ecbed9f70fcb28fb920e3..612de182cf94bc4e91f8fc631318620ccbe6f9d8 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-param.js @@ -6,18 +6,18 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..22842e7781775cf0a9bb8d77a8961ea0fdb36d9f --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-no-skip-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) ; else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..34583bd0c204fbd557adbf63f8088d2b7a491f13 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-block.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..3eafd8d7503c34d4c611e24902b3dc7652de4f5a --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-in.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f27e9ccf81b972becf488f12ca019cbf02d53a52 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for-of.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..67cc2ff176a9bf25d90e7a0c707a8197c9fe2c00 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-for.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {if (false) ; else function f() { }break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..9c9711a68c3e63dc5eff154640d571485355981c --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-switch.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..eee2a2a95fcfbf70d871ca4c62e893c7f9afd4a7 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err-try.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-if-stmt-else-decl.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err.js index d83370d0c48f9b72544fbb0c2d670ce6beee6e60..d07bc2987e80d918a230ad1556d4c3d45f4f2b1c 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-update.js b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-update.js index 2da5c847ba96cc25f696d5dcb280864813eb2868..db17b925f1d7075b52ef58574cb6fb398032eb21 100644 --- a/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-if-stmt-else-decl-eval-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-block-scoping.js index 6482c929e5440f4abc53030786129a57279aa77d..84c9cddd7965a1f1ce005f8c2d35c8a21bf1c773 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Function declaration in the `cas esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-no-init.js index a5c18e6fe8e2c292f60928465200e6892b9610fa..9639be64abcbbc5eec568d7b01bd51b83b57da65 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-update.js index 4ab041a088c5f31a5ce490b72d3a8290edab6d44..d98e2027b76ebc892d6ca5cc916349e4131bee35 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Function declaration in the `ca esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-no-init.js index 34f913d3b0e5cf063781ac7a8476c03c03521979..65738e3f871cbd6a7abddb05112aec3263382beb 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-update.js index 390a660ae5d56ab2e580fb088ff54da289d77776..6e19647bf9e2b70d430bb140097d18f4bc7b70bb 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-no-init.js index 7d36129c1d7aeb8cfcf624904d24eba94f447169..a208a4b7e37193f4c675178ba3b8cdc050b7754b 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-update.js index 29d021449ad8f4b58c8f7390faf36cd17af7eb74..8af5bf4d226952d7861eef9f6b9d04ab24798125 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-init.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-init.js index 428739f2a3649ede2ab418813ac7d4b5c36b424f..266209819c678bb8c063f93c8b2c795ff01a5d81 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Func esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-param.js index 2dacd5cf4f93b9bc02fd168b05259372aaebeb63..de53f14313468ac93a41d30528037faa5ceb4402 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-param.js @@ -6,9 +6,9 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..bc622ce651bd5dc7ffe3ae2bd1cffb3e02d75605 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-no-skip-try.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +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 eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' case 1:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..859efa6f830f713324c4b65123206c422ff22b04 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-block.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..75bb1540c73d53179decbc9cb864f981d9db3f18 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-in.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f413496c112bc3d7033f5eabecc24ac47aedab45 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for-of.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..832104cb7919e3a1a0bdcccb673dfe95acb21877 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-for.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..57112d815e3394a4e2af174d4dab6732471c0220 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-switch.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..356c69ce11f22ed99f902e4f05b10a9e7cfc69e2 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err-try.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-switch-case.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err.js index cc34436a964db76c472be2528301e6d681d63fe7..19ec00827a61bafe925038b4302ed707fc7d697c 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-update.js b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-update.js index c7fbf57083142a6ec83e953e47e160242b3ddf73..644e26b122a3ea9efdfe1760956d8850570fb86f 100644 --- a/test/annexB/language/eval-code/direct/func-switch-case-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-case-eval-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Function de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-block-scoping.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-block-scoping.js index 0dbb01d7480a79ae0f0e88ce847332b189f8cc8c..d27452535e5656f8a1f4fa9f0bdc611b6228077b 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-block-scoping.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Funtion declaration in the `defa esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-no-init.js index 5f0640e062172d6634cd48c7d389940a67a78e1a..2d7a7c685b6389bf456c9453b6c183c0aeb76afa 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-update.js index 36b3aff56f51fe24df02ba624aabd8e7b506432e..6c5603ddea54c2baff7d539a686b96eea4179efd 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Funtion declaration in the `def esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-no-init.js index f9c2b408d4d5f8b186ac44cf439626cc5e030816..6184bdf134775b18c52b592b6a2d0e53da96b276 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-update.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-update.js index 048de34495599f0dcc1b433a9aae3c561757210f..0818ec467d257b0a28da6871cd9dc33451a99d42 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-no-init.js index 121a3372d5281b44434a66c22c0aa6370d254fc9..20093edf1a962e82235af8fe026314a8a1903dc0 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-update.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-update.js index 39e9356d926316b9d4b0aa5f1d840fc5a7b93760..b996c8a34efc1a574b496c97635865a08206d0e1 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-init.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-init.js index 689dbeb0a00a4ed89a7cf46d801b81b3b4c349e0..57ebb3467f6def3b79ab781314fa6d22a51f4f85 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-init.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Funt esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then i. If varEnvRec is a global Environment Record, then diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-param.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-param.js index 3d31b1ccb682efd3a3e3fe74978c6103fc8a7867..9bf130c941f54f619ef831b99b6f6136fc1de96e 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-param.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-param.js @@ -6,9 +6,9 @@ description: Extension observed when there is a formal parameter with the same n esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-try.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..15f79c18ac08a032b136b999e9a37d91361ce919 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-no-skip-try.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-no-skip-try.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' default:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-block.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..7d5a8981905d690079291866d836fbc5a5218602 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-block.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-block.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + {\ + let f = 123;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..94205beedfb7ebc95b9a75391e0bdadd6a5c1546 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-in.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-in.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f in { key: 0 }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..a7b4a00cef571231fc2326d6dfabaf6a08a0e47a --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for-of.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for-of.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f of [0]) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..cf01f546a7c31e9fe5a5dc4faf55e101deef0918 --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-for.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-for.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + for (let f; ; ) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + break;\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..129748fbc843456c5e50ea198ffc9221bc1fc7dc --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-switch.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-switch.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + switch (0) {\ + default:\ + let f;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-try.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..dde36b56ae8c6ea1dd2f76073221c23dad98d30d --- /dev/null +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err-try.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-func-skip-early-err-try.case +// - src/annex-b-fns/eval-func/direct-switch-dflt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' + ); +}()); diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err.js index d9f5fdf8211f66ed309cac0de55ce2c0cddb3a2d..3eb6fa6300b9b924d74c8f18a9fd1cf8871843f5 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-update.js b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-update.js index 1538f7f34b52b3e5561b4c18d09c219fcc2e9040..2eac01615f69ba16daef1570acadd35d6a7c669c 100644 --- a/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-update.js +++ b/test/annexB/language/eval-code/direct/func-switch-dflt-eval-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Funtion dec esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-block-scoping.js index 4974fbc0b8c40d9aef96973eec47a316b9cf4720..86d779531a76ac56b46a8070a08254f88818bbd6 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Block statement in eval code con esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-no-init.js index 8ced75b9c3e36f57833480e3c9bc20844429ace7..a80c8a0c654ab0444a3f5d87f85fc9fa73f1ab6e 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-update.js index f3f3cb189581f8317437225cdbf91af554325bd0..05b2c0f3bd8564856deb2d903d187cf2299bbcc6 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Block statement in eval code co esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-no-init.js index d3bcdd0c81de034782a115543bc50c4eb9051d8f..7b2fcf6c1b7d87ac118a0e552def50b5b2a05f98 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-update.js index b0b9854d38446ab34f9f2218edd5aaf164a83895..97ecf211eb397169f1f47a31c1088cf385799597 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-init.js index e0a8dc661aea86e51ffd3c056c5c403987d54d3e..752a674b0085c237bb6edbcc101f8e3502c22ce8 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-update.js index 7e4e93239c0e881cf4df41d846201fdf04b03ef2..840ac88149b679614dbd04b7b8c2ab99080f0c41 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-no-init.js index 53e01e1d3d2dc1d084fdb628ff51ebb4a31a13eb..17779ac2985fe0375b92fcf35a61339758fc603b 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-update.js index d0859ce95efa5a906024b9e075eb783c6d73a0bc..5e8a0408ec81a6516cfdc0efdde3e69aa98aa31b 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-init.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-init.js index a7c28ba4df44732cd1c67c02a14d9473ba0b93a3..ac9ec0b0b0e4d7c28ff928e7c6f496899c7e9134 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -24,5 +24,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - { function f() { } }' +{ function f() { } }' ); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..b490a5db5c1dedc654d76742118f5bd6ff8747a7 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-no-skip-try.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {{ function f() { return 123; } }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..508ac41b1e276851a9114d10ca365d6b36456465 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-block.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..9485525caac3325c57e1978a86198ba4880fa533 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-in.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f1da1b56b1c276ff1ac5605d3a8b72e51a67fccb --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for-of.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..9113513cfe9210cd94040cf786f292f83bc18e98 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-for.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {{ function f() { } }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..bee092ededad2e771942260690cb2b95ba1cf1d5 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-switch.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..0d054d3c2896a7456fa0a3a80e549b6f9a385fd3 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err-try.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-block.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err.js index 2c52edb5d575554d93d54abdc429567440ed280d..ce88c0b60a4375afed01f66d32f291c32757d491 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-update.js b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-update.js index 70b26bf81c17ee1fc97bc385867e1202facdb3ea..d9d35f897d0a6e2c3e093a99720a306f042a6f73 100644 --- a/test/annexB/language/eval-code/direct/global-block-decl-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-block-decl-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Block state esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-block-scoping.js index 4cdec0c85359979b6b44f44821337b5a961ad186..940921c6748e1450ebc6eb94ed0b1011e4466e22 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js index 03dc38036ed5f7f2fc450522bff45b5246f58297..9abe873d46d336fe6c614b68e02b7ce99d045626 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js index 778a388fd321bb7e7bf59a393fcc1c5a473ff01f..5ffc8449e40d0796f539115d098e079aaf31e9a7 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js index 2bcb3db8ea08c804c9c8a78d4b387a0225253b93..c9169574dc362f7fc9e85888a6ee731c217714a8 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js index 7135f2110cb725b1aa203455b1e7189dbab06cc5..5246a6ee2b8cafd21caf22e53b8e8eb5936e1862 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-init.js index 901a133c55e6b90fbdf6bb6a72757ee7a23ad539..bfa9aa47504c0852b0ed935424b8f3ff1eb4c299 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-update.js index 4c674bb35b609d21fa4f9711c49bfb3f00dc1145..df0543d5381f86630a7298ddbd11180402fec77b 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js index c6845e00431e226cbc82787865e469e9b5be50e5..9f2855b5af63bdc8f7c64358edc93c7eb3040a8b 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-update.js index 248a676056ba7c97d2be84048959bb6ac668112d..a73827418e5a66c81e8a5919be75d12a50845401 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-init.js index 8c890c99131baafac9c3d373c4fd2471ff50ab3f..f3961ddd6879c50ccad47e239f2c254225e272c1 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -33,5 +33,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { } else function _f() {}' +if (true) function f() { } else function _f() {}' ); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..29a0f11434b7facf12202a11c7488dc64072bcbe --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else function _f() {}}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..61a1a3067b802f36a46392d46bd0419f2b145afe --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..d86552ff6f82109581700dc711cdffd41f610d7a --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..74188feec762b29247a0ae1054af39f0e7f72a61 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..b7c48f3f5b84aa8fe897dec7eed490215bf496c9 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {if (true) function f() { } else function _f() {}break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..c5724fd3a28f2088a15c2af5794cbb4bc5211d02 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..5639dbe183954f1e40e969abe0605b150c99f29b --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-a.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err.js index 26257a2738fcab980890535151119584ede310c7..9375a32237ce754c6470e6d2b5bb6cef1c2b0ec5 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-update.js index f0dcf5fec87d7d5d9923caec310c5915b21a4292..915229294e82a5bac288844719b3671aa7a9c38b 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-a-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-block-scoping.js index 9786d4a61c14b9ad693c813ebd2760a26c4f564c..696106433bf1f83b6f05d10126cc9e973355228a 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js index b08c78febc369b5071c983e577f664f515b254d4..ac4cad4d1bd860218dbf4e4962d5a84747103148 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js index 52481dc1ae677e85f4420cb440847ea820486fd8..bd8b973d67ef24e5663c811dc11d3fce5bcb067a 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js index d707e97afae239b8666b05ccbac3d4d2e11a24a6..e26106ea67ef341e09da4f83964fd8847ace6468 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js index 25b4bcf42804d49acf987b55f1af6586791a787c..eeb18ffba4f490ac86d5ba3d3ab7fe18b400041a 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-init.js index b4abb69998604a50c37c112c0b2ab12d740f121d..1976c69f005e3ec301b7f30df959c866a65b8673 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-update.js index 8264e05c53bf16478892d5e7b2c88846cb9c2f06..f6c6c2b396f767db63957843bc188f5978c697ff 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js index 0d43376ae5bba39ec172b28e6e6f4d54ed4bbffa..2210464e287542c8fff8d255075aa5d0d69914b0 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-update.js index a82288f823fe2824948c5156ce64cd6b96a90366..5351488b8a75d731cc61f9baa2c3ab9ebc08d81e 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-init.js index d370cdca50fc89ae1c4a7cb4ae5d1e032b30a078..1663c6b9896660b198bce050c20b52d68242a169 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -33,5 +33,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (false) function _f() {} else function f() { }' +if (false) function _f() {} else function f() { }' ); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..0893c6bf2871bd6bc6963bfd02eb5efb2f9745c5 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) function _f() {} else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..d592c9a89cfed0e03d1b0f6c04bbb1bf673703ee --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..a4983128d2d0cd95051d847cd792088e11a42a43 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..21a83f564332c7d98140a77121116ab0419aac74 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..44d4ce37c17ab5740e88dd2d64af00d103aeecbe --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {if (false) function _f() {} else function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..5d255610c66a4ba5de03b669309a1ce7062ca838 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..619d4ef3037c62ae1cf09f2f53ce0bae08f4b969 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-decl-b.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err.js index 22c6835d04083478dd4605508e167731d5cab005..cfc17963832cbf1a2c4516d7af4a2e89e2accd54 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-update.js index ea556264988004e4b5b041c6730ccbfc1d6d6d90..fe36695ec4096893a6b28fb9dc96f2f587e9c420 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-decl-b-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-block-scoping.js index 4713298ebe5c04937bb8df874bd94da5f88f73fa..989c3954a25e0e8b14adac41710172eca34d8446 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js index cf7e29dd03264cdef2c1bd75e3394eec34eea241..8b06ac5f53a52924556bf15ce93d6555ad1e0df0 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js index 2d0c51b48f06572955634c6c0ac3af9615ac23d1..7a564e847b536592d19e20aef2d195747a88cde0 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js index 16af4eca3be1317abb96e538807dc8385403ca8a..f9a5d6e4aba1673e5fedae2c41b62de5d4f11e54 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-update.js index 8b00ba4c87f14680b20763a295eeeaa097c933c4..87b067e30af5cf8a03193b54bad3775191ac1ed3 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-init.js index b5fe8315880bf03cbc20e0177a10cfd36e42b41b..cc99a93d0cafe7f626fb8f30544e76e2ded65514 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-update.js index dcf3554d53bf8f4fb08b56567dc211f4f70ec7ff..9f63f346ccc76632524438fe397ccffc8ac799dc 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js index e7842b2f0fbc25c26cf44c8947c0c6cd67095a51..b65ad017c8c7be553aa4a05b40e41e4a6edfce0b 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-update.js index 2b58a822793054da4ca3ef781b97cf0b88dc4fa7..749607cdb2f3da70feb9ca00f77c43d4389f4242 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-init.js index a3851495e9bad631c6734945a7c16feb7e134281..a9f6001baa41af45ede24d521604d63cedc0b044 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -33,5 +33,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { } else ;' +if (true) function f() { } else ;' ); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed5f09d0bd13b06c74d47c3ebbe94f571bfa343 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else ;}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..b654eabb62c1d4f8f715adf8698ef6ec41a95dbd --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..c2ea50742e525556a72bac49793cdcf64ffcff5a --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f0e33f36d87f1867c9830e62b417d1ba1f4e252b --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..49fcec3c00d6a8706e0181c830300e76be79a5ff --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {if (true) function f() { } else ;break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..3504c1c3ddc0043ac554f17f95a6659b084604a6 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..ff0a4f9a08128078441b612965b7675719816eae --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-else-stmt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err.js index 5f9e2b9f6ab367491f690100462d39abdb9a5290..183c7011deb660cf3609d421607c8fb566528f90 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-update.js index 6c931d27de3f2b61c7650298f945e6f7b0777580..54625087577b19c7d9bfa39631862baa5e5ad651 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-else-stmt-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-block-scoping.js index bd6703af9570fef66ff600f6c9dda4ef30e9e189..9744b8668484b562fc44ec74e5a086e771486156 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement without an else clau esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js index 5968bdbc9e874e93b9e9d62d5ca146d17796935f..3e18ec4b1b610593072d1a6ff294a51bacfe5ed5 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-update.js index 101b6432c67157d91de78c6b9a0be8d1bccef46c..f65791dc6fadf6ba8e9f2d00bc7a5659b2341961 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement without an else cla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-no-init.js index 9aca52bdc944ae1b44d9e8671bd2ab76d100a881..3c681ec531db3939c0d925a0d5ff3cfe46b7cff2 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-update.js index 4ecde117e39e37fa4006b688abac9d6401e9d1a1..76ec5c1560781cf5632f2119348c438f44ae3c96 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-init.js index dc9cf650f3b3af2f901f21e5b6093320d682909d..92c84cf69b8616cbdad5d7136154ec1d8532786b 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-update.js index d628d593f11dddf541925cc248acea546404e0c1..9f6c90ba1cdfc2349a7e6f733c3ad442b3973a39 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-no-init.js index 8504f3d38ebd6370a328d4799de689dab4b03237..caf029cb1bcf79903ed97767ddca455f2824c52e 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-update.js index 8fdef47cd36e29683039cd0f041ce0e3f57de8d9..b4bfb9df9a971f2076036b1a3b6f8e9a4272b0c1 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-init.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-init.js index 8e23891f12db79be21e81e066b9bfea47f08b0d8..f3f99ed9c93e3730cc58b54f37ff2fd74d246e72 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -33,5 +33,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { }' +if (true) function f() { }' ); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..587073c05eb485f714335aa1be75ba9f6e76f06f --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..4439269297e28513263a9b816c572d60f3440dab --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..f3603f8a6d179c6aa1a8c906b7fe6d389328f237 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..05a80e43ff4449d2cb74431fc443c028c51a30b5 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..b62a236aae9cf57f4f67e7a282ffd541ef5db937 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {if (true) function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..869e5c9f0c55bbcd27afc144d0497f8a51f59666 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..77edf2ce7475a8631a4c2a6d4c158d7c8c22be81 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-if-decl-no-else.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err.js index c82083c110335d892ca0025eeb808de4d2b11e5e..f72f5e9677367743365ae37ceeb729bf91f8be05 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-update.js b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-update.js index daf64def451d59383b0879c4dbb88964cd1f9589..d0d77ed6e94c31a47b305763b4347e74e52ded14 100644 --- a/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-decl-no-else-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-block-scoping.js index 6254f0ec46f7961ae17187e7308d1a74354f3563..fc30a15978639b178f0951aa3be10fe7c4aaf4d9 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js index b20febb44ea062bafa0c0c06ad2bb21aee143ff0..e9523d0937bf82d6cc0a5d18f048b851ebc2565d 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js index 53a09d973292ee91c250a799ae57aec88b47e074..f02922332a0d3e99ce261bcf25e3efc28feb45ac 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js index 70f62635dbea2eace52c66ee5c3cfeb3ee93e0b3..ba34bf1975a3a8187daa52911e84aed117cce01f 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-update.js index b1df92b70c877eff0fe87472608bae4c03f5c671..ec78c56a778317d68a4d002f1c00cea494f890a4 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-init.js index b609db7f0448d8d66a1fff517a3e14a91f559496..344acbf58d15816cb548bdfb8641bfdd6bb7db42 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-update.js index ec5fcb243dbe9fe382ee4ca77154f0531e2173ea..5eb973c40e105b78e6fa15f7886e7840591309d1 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js index 190dae79e517baa8c1e2cacbd35a104de246c420..4567e70674e697bf2d7a6580b5cf159914335212 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-update.js index 4a25ddc36651470eedd602b4fbd7ab0a2484fef5..5338ac8c8fe1e5809730325fb67d8a0347b116f7 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-init.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-init.js index 306e165e1d36a90107d92f999f557eef4b20e800..f7ac6d81a2df1b685a45eca0f237f180ec72c34c 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -33,5 +33,5 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (false) ; else function f() { }' +if (false) ; else function f() { }' ); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..7d311083056a343d8fb8163bd9f1e2321519e94b --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) ; else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..d43ad80bce039d637078ee9ef3d2077d71022e98 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..f9781602feab6dfb743c8373e59f388a6c0a1143 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..9b9f2ea08d4d8f03119b1e583f7b9c4be68aefdf --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..95cbbefc49f575b31a157f701cb8a10dfeec7881 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {if (false) ; else function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..8ee39b4dc0919f0cfc6f2eb125d6976b12483290 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..245b23b7ce65b73623a7c061156efd4c55cea8a1 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-if-stmt-else-decl.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err.js index 6447a04eb99208b5767a20549cd6f44f374ae719..6909220281bb39a67b38bcc22af84609db412534 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-update.js b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-update.js index f847a4a2e12d6fdb461b17f31f73e84f88af0c07..39bbc45c801f99f27ba60232e729f50860c15e52 100644 --- a/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-if-stmt-else-decl-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-block-scoping.js index 4c63c97085c5644b563a3cd1b0c17dca18558332..87d2afa0c4b1df76770a9e9314fcefcf79b9ddde 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Function declaration in the `cas esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-no-init.js index f667c5a82aa58b4d009a16a7892a3fe5f55782c7..07cef87a055f30c6f3e3ca92825bc7bd32404064 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-update.js index f37e200f378d722547fb08ace5a41320c20ce2a1..ff760ab87ffc14444b4653d87c81ff9c8542c5d7 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Function declaration in the `ca esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-no-init.js index d4b4828a61911f653a22c14c81d0e6cea863a4f4..22ce2bcd875a99b465cb46f4ac940341e6aeea04 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-update.js index 3977347b4757eed80d5fe9970c9ac6385da61188..cf1ccd94c98e23c4f9df4f767652b456438db81b 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-init.js index 51c9bae0bdf6a0394130eb6c378e978e8a4635aa..fcef0d95a0374baf32c801de15252f3d5da9bcb4 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-update.js index 0718eea90b50276bd2081887be90332a4b1a2b13..2f72b649c47b247570e670da315311cdaeda0022 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-no-init.js index 310826029da0395220f837e7384b44fa5339b534..4a596ea5ee467363fa26ea4a2c5ee4eef665448b 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-update.js index 5f16b1ff9a69deb4e11d2baf0becf4422c6b3723..8c9d72f7cdabaf5b0c756555872e9a063ca698f6 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-init.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-init.js index cdc416145bc2877183d8eae1df9031d1d61e3b92..aaf3b02192b3ae08a19fe948fad47092ff30d09f 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -24,7 +24,7 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - switch (1) {' + +switch (1) {' + ' case 1:' + ' function f() { }' + '}\ diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..88ea95f0d72d880bf83bbb12a6379bd9cf902e63 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +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 eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' case 1:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..c95e660156656f066d317fe2106cba5231093ef1 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-block.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..c23d28919dd339074c2ba1fab761ddb257d1942c --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-in.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..3aeeba917f2c7a9fb9852a293bb1bc163781be0c --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for-of.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..212e3fb112d2092b5d1485006284eae0ec5300b8 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-for.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..af7caccc1c7f3cbf89ed3b4a9f905a3438e2f9e5 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-switch.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..943cf36d18f644d149db149ab87f942c61cda3a9 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-switch-case.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err.js index 7800e5a36d9561d5d9a0af5736e3c5f092b04c5f..24e399a440295c945d5caf3740a3007fa444121b 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-update.js b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-update.js index 6edf149824cb10b331310beef1d639d6c065bb76..5e95cd911face1c6a8d1980bce267016bab77b56 100644 --- a/test/annexB/language/eval-code/direct/global-switch-case-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-case-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Function de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-block-scoping.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-block-scoping.js index cdd0e8f1f3bdd6af0ce51aba6f5efcd2b730899d..dafb4f2a0a94c7862dd674a3a492f087cfa74344 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Funtion declaration in the `defa esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-no-init.js index 2b0b096bd3476572d78bec4ed7b7b1599676d48d..5a397dbcd8899f705277defec99c68e5ecdff69c 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-update.js index 74dc367ee618073813db3ca20fbd5feea10785d2..4263787f5888e3ab218cfe6c38e12a1dc5e68c1c 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Funtion declaration in the `def esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-no-init.js index f723685d9900e192846c17fe68c713d18503e372..e96586a3168cc66355d33713daad0e76affc2440 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-update.js index 5430a4684d302e412fcd9dcb6a4dd462d93fa92d..0be8fb0b6cd7265e014b0c873225dcd0b680fb87 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-init.js index 25b038a6b58036707936c34cc5e8a27d96f9254a..510bb4d055974c053eed3658a44ea9a8055d89f0 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-update.js index 317df97d479878fc30a2e86cf03bf440a4d826a4..25590ff106c795bfbbb700eaad46c1d22a1643cb 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-no-init.js index e45406c6beab4f055cd11ff6f85bfd8cc31c5c0e..80a285352cf6777d158c15e7968adb318cfe6ffa 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-update.js index 4d5a248e15d57418c646182fd132e951f9c036cc..1502e12f88285476cecf4e73d0b036b11f1ae9c5 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-init.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-init.js index 835afc1886ade6d9cf2dcf5b375dba406b604c3c..7401507727cc0db8663ac2679d14f1bd244bd742 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-init.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ eval( @@ -24,7 +24,7 @@ eval( verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - switch (1) {' + +switch (1) {' + ' default:' + ' function f() { }' + '}\ diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-no-skip-try.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..93d4afd69e6892ef2f6c6134659ddbd6f407a372 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' default:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..9450d935a27e0a24af08d920ba2d07d02de7c9ce --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-block.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + '{\ + let f = 123;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..90e87beb1d6d9cd2b38be45cd7f4c26bd2dc7f31 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-in.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f in { key: 0 }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..15b81219d8e2f413d8f6499ded4f507d8481d7dd --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for-of.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f of [0]) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..8840bfdf36c0a2ff5227cc2810a490924018eabe --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-for.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'for (let f; ; ) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..49d3ea52e2878464782c3d9d94801f6c8c217cf2 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-switch.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +eval( + 'switch (0) {\ + default:\ + let f;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..917c03c18edef033bc77672a34b3034c1e33ce10 --- /dev/null +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/direct-switch-dflt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +eval( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err.js index bb7ebb2dfd7cca8b4111f3c6a8ba6d3eab612c8f..02cfcb07403bcd8f97eeaa0155c2799c6dd41d5e 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-update.js b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-update.js index 4b7e30b0f9457cfe0fd2c25b68476e08a8ce3b9b..112b4280d2efd118bc960fdb4f7957e1b97275f8 100644 --- a/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-update.js +++ b/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Funtion dec esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-block-scoping.js index fb38b478cb595c48b63411d8347b8f2ed7aab299..281aff6b42152dd6268b7b9769d5830deb6e4f78 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Block statement in eval code con esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-no-init.js index 92927ac11ff70c8b03175087fb5ceb31cab74b03..101ce7b5246ade6b087bbab460aa2ef95f45b1cf 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-update.js index 8b374b4f885f86752b46f923ef740d9ca08e4c37..4015d0a19ecad30f13548278f58f4449bc539eee 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Block statement in eval code co esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-no-init.js index 6580ff60395a7fdc4f42cd44a76be5676a618944..85144b8138a6d7b5972020b23df1ed7aa60e95d1 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-update.js index b31d4909b6af5ff7fc2947a2c8ea224c47c6d001..589772c8343bd2676fd1fbef778bdb11f5f8f811 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-init.js index 5cc515e2a83d924ab5d8e09c5b2abdd7a3385e50..2d819ee16d30a98acfa631e9001a98742edfa070 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-update.js index efeea1a32c5683804de40b6a3d545741d85d0e01..1e77b0e1e2daf28a839f444a7041c7bfdfe9dbff 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-no-init.js index 38f976d2bdd29ff02c10c53e1e981784a16c1db5..52722c3c0e4c49ef5214d900cbb3898258e8166d 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in eval esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-update.js index 40273b0800787dfdaad0117cc7b1bb4f5a169d7a..9f6abc217000fc956642410a501c67ae3ef06991 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-init.js index fe56d1e397b2615fedd7e427b4087573fb096507..250df9f71864af198fea86b38f6d0752fb07d9b7 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -24,5 +24,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - { function f() { } }' +{ function f() { } }' ); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..8ac84251b3d9aa1e02f784cdd167ca256b16daac --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-no-skip-try.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {{ function f() { return 123; } }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..100f1f4a862123924fd7db66b0b2b53481e3a4c2 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-block.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..ed612d0c16ef43250164e06df88d4b514d30e8f3 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-in.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..a22ed2f5822d0f6e7de041222d291bb8c02e0777 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for-of.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..a74ddb4ae27d7a41203a7ac6ef4dfc2522ea8209 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-for.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {{ function f() { } }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..62b12b24aeec22d761915197c618aaedc851435a --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-switch.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;{ function f() { } }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..5e4fc6e6ed7151260e7d3b1a8e5b707bb6e3cbc9 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err-try.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-block.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Block statement in eval code containing a function declaration) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {{ function f() { } }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err.js index e7b1f3e10bbf43447da7f28b9478b9b52be9c81f..c729084a84181f2a15d073ae2fdbb71ff07a9b30 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-update.js index 8019354cb379b8a36f223a013439f5f18f5c3ae4..79a0c9cf9a9e5c70ef9ade91d9f7f431e4474d44 100644 --- a/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-block-decl-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Block state esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-block-scoping.js index df0a4e03671e03761072d3f22f34138bbbf88e93..8c368cd319e545bd1468c5045335a65dd6cc1a4e 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js index 3a4cfcc5b43ca1efd39eeead85a691ab1a34d950..eef5e6ae639b74a08c04dd9bcb64ded5c410158d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js index 68d679d5f0aac3dc9caaa40528104d542329bad8..41086486ece47568c5d8230d961ce7cd80732567 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js index c2abf1b3e63a357340012288db971b0c919f0d02..de48fbab706ffc9f10564a44f3002b1d849df6e6 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js index 9591f59a175c76be13d830fc6d3f6701c975c8c9..05bbf83befd530f017745ecd1859eaf38252ab60 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-init.js index 8ff100839ad486cbdeba02eaa722fdd71b1b0df1..52655f844b8f4f1d627ddae6aa810334eab3d7e3 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-update.js index 8044e4915c8c4cc86b0d796e5a484ceeee3b8d29..ad7723acc41f86665a43f4a77737785c8af1fa67 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js index 4577d09d27202f886d3f10c880853f80fae10fc3..00adefafdf071636cbceaaf4247a302398098505 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-update.js index d407779f00db322f74e354981e21c9699e657420..d8c87d6346068e5b7e166f595a5597baaadb9bbb 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-init.js index aba07748b8774638cd9ac19ca3f5017be2dcea0c..a3f93712168771795bb11d7d664ea07c144f06af 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -33,5 +33,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { } else function _f() {}' +if (true) function f() { } else function _f() {}' ); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..0701f50f9c332b10f7dd0969a9379c604d1bce4f --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else function _f() {}}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..e567da475646ee17eec3dd809cf1784cec4274a9 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..7f2ea0ef16d230bc9b734d2fcc92fe81fe664606 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..3d3f0cbd1e71104467f1a2f8ec12cc5d670923a1 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..60dd5b57a87ac8bf13b45b648eaf077d1298794a --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {if (true) function f() { } else function _f() {}break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..a2b8924930bfb1455b78f9129a7cd3cc83b09976 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;if (true) function f() { } else function _f() {}}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..a52c846da250b8fba6971c7b6d9bf38c71c9de64 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-a.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.3 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else function _f() {}}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err.js index ee5dabc1625b809a1d04ff89b6c62f37e0fb70d6..4d12d4b2279450400758ed68f80b551114b120d1 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-update.js index 94e1571bdac39958a071b3ce675ce2c967633fd2..ec63ec14fb22c56ede04d9c346276ec52f177cf4 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-a-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.3 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-block-scoping.js index b9355710f8298044e15034476dacc9e6d0d06b24..75e3ff104c44c200432627c20f7e5aaad0bf34c2 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js index 03ac26f6e78111ec99795910d7d7c8f069d075e6..acc25ae2c066f5e8ba6deb5c1e031c82b0a6ed61 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js index 8e07a11285792fcf9d226c6203744dca80742c9e..beb319ef01dca7b2f29bcbdfe2a3632a2fd53a8d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js index b84e00d82b72f538ab16442290d3c4dd77ea8e34..96067c9804262c6a1cb5890674d8c7cc35dcd91d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js index 6cea720b296ab6413634a94045576866ca6fee64..555d969eb554fc17a219a6364ca69e549a8b5898 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-init.js index 93254ec269f6907f536fa514babd0147d2d8677f..f899844a6a3de69fb331ab8f11995873b590642e 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-update.js index aa1d8b26a6590344987dc5575ed679dbf8fe50b0..5cf0cf1b2bf2fa419b9a172cff47c261158feb87 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js index fbad47187a8b70fec0e6fef6ae87e034bd7d94ee..4576fd8cac67bf2c5ba6f8771ba22d5d82af1b82 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-update.js index 991044ebfb816158395c837d46db506aa212e469..aa41be9bba4dee09d6b1a2b0b8f3e1cfc8e5b769 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-init.js index a817f65bd061cacef3bafacc8249c8bbda127e19..7054756a4c8367323b112c08348341b1b98a8f2f 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -33,5 +33,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (false) function _f() {} else function f() { }' +if (false) function _f() {} else function f() { }' ); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..e61266ddf00d40aabc03896fb0ee38abbaa666e2 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) function _f() {} else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..839a640fa189148d9f0907f1d1bcc266692e5f5b --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..c35901a11256f9385d90afca606a2779178ce7d3 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..25bee4da59c6a7f087cd17799ad7555c0de219e3 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..8bf570ed93242aeec6598327f15bc8ef409c1b2a --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {if (false) function _f() {} else function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..691df1dbbdf9da22fff02eef980081981d9574f6 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;if (false) function _f() {} else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..8f2c3bf27ef0fdcf0dd71c2072dddd417a788010 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-decl-b.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in both statement positions in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) function _f() {} else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err.js index 03d0d408c01e914b50698b687cc74a42fd9c7e24..e0c4ec4c5736983bcaecefb4ee305cb0f4e59be2 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-update.js index 30b32f786b276dac88937b21e17db12f8b698476..1290d0831f9b67f4d0850be4ffb9062de000eca5 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-decl-b-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js index cd558c772b253dc4b02f7de6b46fbfbf1048332c..b26c8833dae8e90ada4ba11ca680aafd0b99dd29 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js index c6d352e046cca5c6ae314d843316e368781eceb5..43d41890068a8998fe30344cd4e4bb6bae8d9e41 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js index e4c2c902dea782b01fa1cca8a188537773513bff..c09bde6284ed62c553ee8a35cbc933b6db258406 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js index bf6084830afbe40bdb9fa00fc77790d78114e9dd..f88f2122e4c5bdf429dcb315480bef471dda91cb 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-update.js index e5326a372283ca612bf8f9fa50f12c53cdb5e11e..40d0438c6c56e07b499c0448a8e419251065048f 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-init.js index d94fb8d6c592fdd479e005125b18ab4ff9433735..1190285edb114d5868ed112d2afcc84bacefe5f0 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-update.js index 7c98c96a45f85d195d927395f7f97173bfb65d13..2d58315decd51d8c74a40a08866c1fd0f010d8e6 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js index da8eb93b3022888fd1f941fac1098c5fc87973f4..1e61af9519de24904cd7be5646d5f162e8c6f5ca 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-update.js index 5304fde51ca345aa314386220b174b9b4d274063..e42177ef201980869306f087ae5224f24a810f7b 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-init.js index bc49b2957f850acaf9e5fb0fb0a70c873d484fc4..7208aa773020b7b2c0ec8208167bd4d9bc870cef 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -33,5 +33,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { } else ;' +if (true) function f() { } else ;' ); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..dc81cc78656f5df1d410ed11b917c784548efb3a --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; } else ;}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..332473d5c99a1d1748e75055d1f3d3c9d08c9bc8 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..5956c3dff6df0be47b9c8f190105b0c369b8e466 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..9c808eb2820126d3297d41e0f5d680f607289ee0 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..b9604dbe8054073f6f806fd0d7bb26fe7c9653c5 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {if (true) function f() { } else ;break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..615d835343e2852ff465fedce7c5f18c2c9b6f3e --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;if (true) function f() { } else ;}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..e49acd1a41140ea2d43287b0fb3ec7aa458fe5d8 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { } else ;}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err.js index b4e891edf3a8b5ae187a3a447d74a5fe596c3839..708a92f63fd11bd1551064ad9adaff000427de15 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-update.js index 313e29c378fc9b7292879aff7fa0d19cd9dfd18b..9173cc39d4e20f475b542aa826a0ebf9c4e23a38 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-block-scoping.js index ee20009cd6596b0c9e37a28bc23b7c7170631c4e..c5690a30f2ded95d52f19ba6a3634334f74edc42 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement without an else clau esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js index 51bd5749cb5f6c8d8c81cb8517246a5ea60976b9..f948b208f7c4d536c57277ef49a0376a60419c9d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-update.js index 104442ef2be55daa5133201b7c78c3705d8104bf..3210fba3a5fe89c13fa80b4a6f56485dcf5b1547 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement without an else cla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-no-init.js index a3221fff452274d75f6028197286e04d0a55cb94..e49810917ceaf57d835da73a80bcfc02477ee0e1 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-update.js index 87d38cf413fdb1132f97afe0d8ecec4b0b96413b..f0cc6c827391aec573e5c14ad39b38b29115a453 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-init.js index 4834d37f8a018328e56b73366f98c2a8f5709b88..98ec165ffce919886573349978ed07a0a13118ed 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-update.js index 9f997fefbf0ed443a7cf957d43976104bf97873f..2e617301fe183a627e321e4ff1e62befef022e52 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-no-init.js index bb8aa83b47f48a70e316408754d0be606fae8286..34c9a9c3333a1f4b2852791f86dbd2d2eb3c4fcb 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-update.js index b0bc9fce3d0ac84bb3a109bcae4f60b6d991a43d..344fb9bf7855948821cf8d2a134b4f1433f6b91a 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-init.js index f3db0a749fc91f48bd9ba17ddc18ff721022ed51..bb889ccd93875bd6f16388a702d3bdb2ceacd15d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -33,5 +33,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (true) function f() { }' +if (true) function f() { }' ); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..bb8710bfd8c46c40131e3d2a63b26ca151027d15 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (true) function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..1469c0560867e93fee5181305f07dbdd2e685960 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..b2f31f0765228ee31cd6564eb60223554203a482 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..20b50c2c1fdd92133b123dc753b5f383a7695e95 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..2342001e523e0ef5c73616461ec4fc8c1b0b3984 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {if (true) function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..d1ee6539ae8f48a22231f1896cbb144561b84097 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;if (true) function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..5a4bd7d4f8a2853ad8203139c815dbf68d7b9c40 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-if-decl-no-else.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement without an else clause in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (true) function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err.js index 97e614cf18382bc21209eadc148407a6d829bddb..7b26e625ce9d372573101b166c0d81fcbad429d5 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-update.js index f2386f1a382181c548a2d4e2e22d0d3398bda81e..929678653ced6f85d1585ad7bf2557d60ae91927 100644 --- a/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-decl-no-else-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-block-scoping.js index 71efc9ef750a2842df7d16debc6b9a030d6f304f..7c5aae05e0dd05efec294d2e98f35a9d1d72ecf3 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js index cbf132fd179c22105f36cc68fbc77530c1b216c5..2c0f2d87fb080a3edd30116d087bd58b46e7644c 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js index 07fdce016dbad4c4841f1b4f4b5a951f2dfd8af8..177f234a26062b26f37857b3a2ce588086309b05 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js index b25d4cb1eaa89aef10e078db8ea757fc2ad8ff5f..498010a114951641c8cd6c64ea6d9fac45e53502 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-update.js index 6dff085975d930e4acb465b4c8225eb6a08353e6..496731b390f8daa320ad0eb0710774ad4a848c22 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-init.js index 1c89e330cd0a6e4c45e3bf4b798b4013fc2dcab4..88f5a81a6f14e58dc3543fac6f4fa246cf6f0a60 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-init.js @@ -7,25 +7,25 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -33,7 +33,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-update.js index bb1f60520afa67ecb5573f2a94ec1ea4c09d5b74..1a2c91b14595c3b347350e2c365c77a2b993700b 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-global-update.js @@ -7,18 +7,18 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -30,7 +30,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js index 2ccbe3994d65e5e45b83690017efad463639eb74..49b5bc6398f0dd70dae693dc7e50a89fccaeb77d 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-update.js index 124f502d031568d3d5dcdc30dc66609760d1c634..0f2e559c936548070ec39cd7ab01031c84eb0063 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-init.js index 774168f103459d58e11f0bfa6e38164629656a60..a223be102e389947d9592327df370deff0df8c74 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-init.js @@ -7,23 +7,23 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -33,5 +33,5 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - if (false) ; else function f() { }' +if (false) ; else function f() { }' ); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..3addf9af6a4c0ef0c73eb599d62b9459b9c333f3 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-no-skip-try.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {if (false) ; else function f() { return 123; }}\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..617d6e0bc444cc1784db504640ad331aa32c1b71 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-block.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..fc569622bdfce92c0a7d30f5b28c073c387c5fc9 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-in.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f53d893c4f1c33c4334070d294800b24b6929242 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for-of.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..1fad833946b9807a528535c32bfdf6c1efd2cb06 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-for.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {if (false) ; else function f() { }break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..d4ea74dccced7cf456a07607a1ec32914af3f4dc --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-switch.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;if (false) ; else function f() { }}' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..f5ef79b77bf4a70c6668d714d5d9c98ec313aceb --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err-try.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-if-stmt-else-decl.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (IfStatement with a declaration in the second statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {if (false) ; else function f() { }}\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err.js index 3b7e38c39dce3a2637dc7bfbb0b59c1e9e0907b8..2ecf0c87fc61eeb1c3ca007917c84a9c3de53a0b 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-update.js index 20f7f4060f93939f578d41b038eab69dcc0df695..a5c6f3638a5449edf21764c10e88aff56cd1d7c3 100644 --- a/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-if-stmt-else-decl-eval-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-block-scoping.js index 5583ab9bf4d787d5b061d40b845ebabcb9293177..8e064e36935ddbd061f54595077d1eef9de0a6c8 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Function declaration in the `cas esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-no-init.js index c5f87145ed5774e842a268bbc3928d98c7cc69a4..7215acf018cba695fada6ac951af5a6095c7e88f 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-update.js index 7ea3150d44f5eb2ff37100ef9c6115e622da19c4..476bf9f9ffbf5a85ca8a38fa67e9636524c66c9e 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Function declaration in the `ca esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-no-init.js index 833bfe524333adce6980ffe1434c1c9d41ce9151..3d769c29a9f10b37abc79260a2bb0a2c558f6cee 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-update.js index 6ac05bc441ecf2cf6881270f7086b921174d9954..47e337b27839955289016b80855beb502d1c4b32 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-init.js index 8dacef7ebdf3e560dd616ec2469d7e0f388a340c..a5ba9deb16100ffe7018976b8e181a748d08e860 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-update.js index 27611165a70751d3e621d037677c1be3aa19b7c1..607fb06172c838f56f0c7023d59def30c1c1b9bc 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-no-init.js index 925019d54033c0a03891b88808738e5edd9e545b..ebdb9588bf7695c6a55c075fad72cd92a4e202e1 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-update.js index b2b0a808f5cd3b0965c0eeae3071b5c548fef495..69d6a6e1d6273e3b1c440ff5a23af95e791605fd 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-init.js index 47578f960cdb1253e6de87bac2a35145499495d7..9e05d398f8e1b75e3d7028673255d04b359dd0a9 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -24,7 +24,7 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - switch (1) {' + +switch (1) {' + ' case 1:' + ' function f() { }' + '}\ diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..74f4158117250e22d9414362ffa8224bab1163b5 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +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 eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' case 1:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..0004c08b15c87574552fe2906554957f445bb09a --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-block.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..82bb484253062d65258d3386a5a1c1a55d2420a2 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-in.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..5ebb2c54d1dd6cdfbe3e8259659abb04b08d7982 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for-of.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..06850b06b62c02d22931a02a00f79ae88b38aaa0 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-for.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..fafaa057011e59873e487c8d39764fe9678ed315 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-switch.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..9503b016dba95b8fa203e612603ee9ef09b55e9f --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-switch-case.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Function declaration in the `case` clause of a `switch` statement in eval code) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' case 1:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err.js index edeef7fc01ba52372b1627c2dd2b820c2bf678ce..c6b601b280f22ab982ee44add6f35d2fa5aee7a8 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-update.js index 85a67db6844ff69c3a6cd2cc602aba6f5bfee73a..eee6b62f804c529ef797921407c5d6a39795d9e1 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-case-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Function de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-block-scoping.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-block-scoping.js index b73df235ff69273f6955ff1de23126a0e6d09c6d..3c3b791a9b301161b96407ff9a9e5dceac3278f7 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-block-scoping.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Funtion declaration in the `defa esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-no-init.js index 723b7331b707996cd2008ade146c651a8f944a29..59d7cd0616e8034d9c7609743cb38ae04c8c41b8 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-update.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-update.js index 32391f34a75ede2a07a6c91c53e4da10dc828413..f91889a7438c1af953cc19ac2f7c71607bcdbcbf 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Funtion declaration in the `def esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-no-init.js index e244e5629d746a838331ad397ec0f33490f5f33e..20e4b80c095a4fcb3ed1df03dfc0bb2a36689435 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-update.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-update.js index 9c56ac916ebc53a64798aebf2dd22a3e8233cb6b..831f1fccbc23a549f1a0701db5af5819d02664d0 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-init.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-init.js index 3f0264645f7e3ede472c454e42794af71951f440..826f6a84917644a57f9b7a26e3aa54583b771692 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-init.js @@ -7,16 +7,16 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + 8.1.1.4.18 CreateGlobalFunctionBinding - + [...] 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then @@ -24,7 +24,7 @@ info: > 6. Else, a. Let desc be the PropertyDescriptor{[[Value]]: V }. [...] - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: 'x', diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-update.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-update.js index 3fa35bf0e71ffe72915d3e8af27588a40cd6f573..b3bad895f10a8951e2fab5026cf0286f2c7ed858 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-global-update.js @@ -7,9 +7,9 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -21,7 +21,7 @@ info: > v. Let fobj be ! benvRec.GetBindingValue(F, false). vi. Perform ? genvRec.SetMutableBinding(F, fobj, false). vii. Return NormalCompletion(empty). - + ---*/ Object.defineProperty(fnGlobalObject(), 'f', { value: function() { return 'Another function'; }, diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-no-init.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-no-init.js index cc1ad62763e5feec4a1a6728e3f5820b644951f2..2f900f699297a3bb4a579ba1120c3a3e997bc812 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-no-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] a. If declaredFunctionOrVarNames does not contain F, then [...] diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-update.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-update.js index 705118ec59ebb62362a4886f4bb1b39134c50aa9..85fdd83f77a0bb2673f11047c03a67c0c239cb67 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-init.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-init.js index 74d444688c44e056c0dd64557c6d8f61c963b010..c9eb03bc77c9b2dd8ba71ab41497839e9f5105dc 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-init.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-init.js @@ -7,14 +7,14 @@ esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] i. If varEnvRec is a global Environment Record, then i. Perform ? varEnvRec.CreateGlobalFunctionBinding(F, undefined, true). [...] - + ---*/ (0,eval)( @@ -24,7 +24,7 @@ info: > verifyEnumerable(global, "f");\ verifyWritable(global, "f");\ verifyConfigurable(global, "f");\ - switch (1) {' + +switch (1) {' + ' default:' + ' function f() { }' + '}\ diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-no-skip-try.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..95308f71d9b5575ec8c1141559f9a8d386fd882c --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-no-skip-try.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.sameValue(\ + f, undefined, "Initialized binding created prior to evaluation"\ + );\ + \ + try {\ + throw null;\ + } catch (f) {switch (1) {' + + ' default:' + + ' function f() { return 123; }' + + '}\ + }\ + \ + assert.sameValue(\ + typeof f,\ + "function",\ + "binding value is updated following evaluation"\ + );\ + assert.sameValue(f(), 123);' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-block.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..5c12cdaa0fed8e79f8f98ce77ec6a52a1b2b9dbb --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-block.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-block.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + '{\ + let f = 123;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-in.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..9b819ebd737a3c3218959355f348e27b5965a8b3 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-in.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-in.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f in { key: 0 }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-of.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..4a12e736bf9f7bb78b04dd9bec6e4143725df405 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for-of.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for-of.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f of [0]) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..cff1e2c77af04d426a1e342df307a73b0eee05ce --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-for.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-for.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'for (let f; ; ) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + break;\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-switch.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..b385ef5c2731e0ef8acfba3c9eca83d851ea3b1c --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-switch.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-switch.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +(0,eval)( + 'switch (0) {\ + default:\ + let f;switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }' +); + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-try.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..468c49d21f03ca65f530666dc4c073071831c831 --- /dev/null +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-skip-early-err-try.case +// - src/annex-b-fns/eval-global/indirect-switch-dflt.template +/*--- +description: Extension is not observed when creation of variable binding would produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope) +esid: sec-web-compat-evaldeclarationinstantiation +es6id: B.3.3.3 +flags: [generated, noStrict] +info: | + B.3.3.3 Changes to EvalDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + body, then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(0,eval)( + 'assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created prior to evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created prior to evaluation"\ + );\ + \ + try {\ + throw {};\ + } catch ({ f }) {switch (1) {' + + ' default:' + + ' function f() { }' + + '}\ + }\ + \ + assert.throws(ReferenceError, function() {\ + f;\ + }, "An initialized binding is not created following evaluation");\ + assert.sameValue(\ + typeof f,\ + "undefined",\ + "An uninitialized binding is not created following evaluation"\ + );' +); diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err.js index 164efbd0beb9c8a641d900f089966747f7951bc4..a347e35825743d348558058b5f9c1fb11c5b5cf8 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-update.js b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-update.js index 0b2927ad0ef41e7f69c85e990718820cb7d65427..d737002a56b274723ec394122d6a6b4692bccb33 100644 --- a/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-update.js +++ b/test/annexB/language/eval-code/indirect/global-switch-dflt-eval-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Funtion dec esid: sec-web-compat-evaldeclarationinstantiation es6id: B.3.3.3 flags: [generated, noStrict] -info: > +info: | B.3.3.3 Changes to EvalDeclarationInstantiation - + [...] b. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/block-decl-func-block-scoping.js b/test/annexB/language/function-code/block-decl-func-block-scoping.js index 8027175fbb15cd902963b009ba5e6c5a7c4d30f6..fdd0726eba15f53d3391e0d729f423b6232e42a9 100644 --- a/test/annexB/language/function-code/block-decl-func-block-scoping.js +++ b/test/annexB/language/function-code/block-decl-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Block statement in function scop esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/block-decl-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/block-decl-func-exsting-block-fn-no-init.js index 775799c6066db69adfa072f504996d6ad3b90900..95002d0836571ff3444fff02a0168349fc101bb3 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Block stat esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -17,7 +17,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/block-decl-func-exsting-block-fn-update.js b/test/annexB/language/function-code/block-decl-func-exsting-block-fn-update.js index b566359f9c4f4c8dc936671de7ae0487d2e0e902..79a84a0a0069fa5a806ae51b9a9029a89d127172 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Block statement in function sco esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/block-decl-func-exsting-fn-no-init.js b/test/annexB/language/function-code/block-decl-func-exsting-fn-no-init.js index eb98135ff7c851daa23ede8e41ae6c3c3b448509..22dee65ccfd73288d9de9594dd7fc5ce59dd37f7 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in funct esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/block-decl-func-exsting-fn-update.js b/test/annexB/language/function-code/block-decl-func-exsting-fn-update.js index c4e5ec6c98b2ce4c1a12b6b6fa9bc370307c030e..61b188b42a5308b418e227090c0d2b959204ae81 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -31,7 +31,7 @@ var after; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/block-decl-func-exsting-var-no-init.js b/test/annexB/language/function-code/block-decl-func-exsting-var-no-init.js index cdcc4afad0a8dace4542ad8272502c2acdfbbd74..2db631920988607ced25cab6f4c421af160a72ee 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in funct esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/block-decl-func-exsting-var-update.js b/test/annexB/language/function-code/block-decl-func-exsting-var-update.js index d95b7ae2babfec60bef1fdc373a2fc5b87c37b65..fa1865a6efc2240561babfd35bbb0217c4e83b50 100644 --- a/test/annexB/language/function-code/block-decl-func-exsting-var-update.js +++ b/test/annexB/language/function-code/block-decl-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -31,7 +31,7 @@ var after; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/block-decl-func-init.js b/test/annexB/language/function-code/block-decl-func-init.js index d3d2fe205fe25b517a1fd22e16d66c7d443faaff..c50a913c5b1629dba9ff23030cb081632d5ea7d0 100644 --- a/test/annexB/language/function-code/block-decl-func-init.js +++ b/test/annexB/language/function-code/block-decl-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Bloc esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/block-decl-func-no-skip-try.js b/test/annexB/language/function-code/block-decl-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..86b9c8c2d41bd02eb9dfa40dd21b73580f38ae6c --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-no-skip-try.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + { + function f() { return 123; } + } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-block.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..e73e4f0d4d7a6e5af7977a3eae647b701ff63326 --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-block.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + { + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-for-in.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..cd3835e254a32fba1f6cb5df8bef59ea80d3597c --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-for-in.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + { + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-for-of.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..42bdb58fea3b7929882d4c67912d151f4edb79f7 --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-for-of.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + { + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-for.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..569b97d8a2937f3098cb40e89c7d2ade6f4eeb15 --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-for.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + { + function f() { } + } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-switch.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..6d56fc2110a9953f58ae41c313285bbdd6f24c44 --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-switch.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + { + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err-try.js b/test/annexB/language/function-code/block-decl-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..378c0bc44b5c8da6d222310bba09a02810f674ba --- /dev/null +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in function scope containing a function declaration) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + { + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/block-decl-func-skip-early-err.js b/test/annexB/language/function-code/block-decl-func-skip-early-err.js index d2a82ae8f75dd8305c737a660e3fc2ad0ef32a98..461221ec77f72ec6cf03fd93445b8e70d00d8b1b 100644 --- a/test/annexB/language/function-code/block-decl-func-skip-early-err.js +++ b/test/annexB/language/function-code/block-decl-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/block-decl-func-skip-param.js b/test/annexB/language/function-code/block-decl-func-skip-param.js index 291bca792e068e3a9e3603c75f8fa3beef684c3b..29490bd4f94c924a0869433d090d46edb0ac7066 100644 --- a/test/annexB/language/function-code/block-decl-func-skip-param.js +++ b/test/annexB/language/function-code/block-decl-func-skip-param.js @@ -6,9 +6,9 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/block-decl-func-update.js b/test/annexB/language/function-code/block-decl-func-update.js index b4b52c24b94fa7c72d77761f22baff1a26392de6..3c858d6d7a116626aa5dd3d17816ab4dd030fd2c 100644 --- a/test/annexB/language/function-code/block-decl-func-update.js +++ b/test/annexB/language/function-code/block-decl-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Block state esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js index b10ab8a66617844dfe3b7c9b4540352940ce96b0..a9a2a831aaa24164bc65a273da5fafc7637904eb 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-no-init.js index 30b36aba57f827b035223e84425b5edd08cd6829..fb4437724a0d364c304d6ebdbb9fabf061c7705c 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -26,7 +26,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-update.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-update.js index e49148fa2a9c6f835d153e664c9a483dd951ab4b..07b1d4661f6e8b1192d85d78d7bb5a0dcba0db89 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-no-init.js index e1f36fcc951dc6f9ee2a27e794107e530174af70..e4294502591ed7b169bf5024d950730118811189 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-update.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-update.js index 9a00764b1fb2dd089ddde253bc140ae579da85fb..12a44f977a13fe5b9437e116338e5db0be1b7ae0 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'inner declaration'; } else function _f() {} after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-no-init.js index d885a042c7c524fac19a3255c6b33c1955eb2f4d..c33e999742bdcb0d1718db396a508532aebcebb4 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-update.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-update.js index e9808222a20c2e19574cca64ce290efcfe83c61e..8b3d66a3f1062fa6c93e23d3887805120f72e7ec 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'function declaration'; } else function _f() {} after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-init.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-init.js index 6399f2fd1d15ab336d91efa674988d7026f5b508..9baf3f2751f75ea8f482d421516331ec6f09e2cf 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-no-skip-try.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..a42812585b594900d53451ba39e485b3ed6bec26 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-no-skip-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + if (true) function f() { return 123; } else function _f() {} + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-block.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..7db55629a74d0bfb933982a7ef88ad7779318fa9 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-block.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + if (true) function f() { } else function _f() {} + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-in.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..c619fc6870cd1637613223c63c1387e38d4ede9d --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-in.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + if (true) function f() { } else function _f() {} + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-of.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..1d745b6a5020f2356a09b0f0fc419bde9de2b2d6 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for-of.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + if (true) function f() { } else function _f() {} + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..9b65881669132bf06feac050dac6d5b326d39e78 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-for.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + if (true) function f() { } else function _f() {} + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-switch.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..95e35df90644b5d627ed4c1bcedfe6fb19a8a5d4 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-switch.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + if (true) function f() { } else function _f() {} + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-try.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..08139b1d2d610dfd78047b1f3c30c81d9d04899f --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-try.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + if (true) function f() { } else function _f() {} + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js index 809a5b33bee188a9bb2b948e73e77f42e28b7c36..b3f9a20a1f162143928186eb0ed98b056a0cdce6 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-param.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-param.js index 1ff4227bc68cb5e405eb2797831f61916f7728dc..430927eb63e1c4cb8aa3eab753913cb5403c1d94 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-param.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-skip-param.js @@ -6,18 +6,18 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-decl-a-func-update.js b/test/annexB/language/function-code/if-decl-else-decl-a-func-update.js index 4a54419e10ad394025a29d23074e78ae38601717..8c9fbc3e51120dcf4b50e44c4ee853aefecaf58f 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-a-func-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-a-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-block-scoping.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-block-scoping.js index 3b34452c789e4ed05ed4c3822ee68d169a0de8b5..330e936665c50332ea22c13526f3a6be3c3ef6a7 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-block-scoping.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-no-init.js index fb30755673808a437b833935c8baacad9d9b35f6..be7d4e1f0e9aae17fdd2c8d9332f352c802cc498 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -26,7 +26,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-update.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-update.js index b602cc8f739586639f17039d59ec84e4ca01cae1..0de41bfc76b1fdb7779cd9d5d9cd7a7cca1efcb1 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-no-init.js index 2777bc5e0e0dd9e6fbe270eae7498a49da619833..361628ab919ece1ffb4c0a2aa1230fa75a6c1e5a 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-update.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-update.js index f1808d08d08eed7b392e7796a1b4987040823ed5..e8c7a6a59cec18ba2992e36a11813957240e9087 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (false) function _f() {} else function f() { return 'inner declaration'; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-no-init.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-no-init.js index b60ba50eb0d781c4fefdfc444436a6e97ffd5c14..c4e97e929dff6fed7d04c7a0e69c38459bf1eb99 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-update.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-update.js index dd98fa4f30f9043911ef1bd7ae38771a9cea1035..b2695d8eb4c0bb2c12e474ac9854c76345be1af9 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (false) function _f() {} else function f() { return 'function declaration'; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-init.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-init.js index cc36c1b86b92bd2ff43eeec51a8fd117d798fcfb..2192abacf2c3ab1b5190ebaa67a52a4b52553260 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-init.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-no-skip-try.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..e06a593e8ba77de156b7a18317083df895fc0c24 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-no-skip-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + if (false) function _f() {} else function f() { return 123; } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-block.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..432946beab53c161d8f93c226b43934fee24f848 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-block.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + if (false) function _f() {} else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-in.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..414f8254fb51b34f8d975d5ade39c89e1044754e --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-in.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + if (false) function _f() {} else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-of.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..555e87531bca58c272c473681bbd1a5fd471d804 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for-of.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + if (false) function _f() {} else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..fe41660e4def1b9e4c7ccc49099d2dac2210bddf --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-for.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + if (false) function _f() {} else function f() { } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-switch.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..51e66f0741ddd5ed36f6790917249449c2be6626 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-switch.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + if (false) function _f() {} else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-try.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..86114b14b0e4b1974bb62e6f673a01f775132bae --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-try.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + if (false) function _f() {} else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js index e09174b2ab4ee0be27a4906e7f35719246bc7c1d..8747ce60d19733d9f18fbe27e6fbf727e078beac 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-param.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-param.js index 12668cd9518864c85f8110cbf393d8708ef85e87..ebadc1d059d117de7d2d9aa5cab907eac9aa4bcd 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-param.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-skip-param.js @@ -6,18 +6,18 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-decl-b-func-update.js b/test/annexB/language/function-code/if-decl-else-decl-b-func-update.js index 363996a92bfbcbdde426c035e09dcf7b1c2a2a31..0220cfcd23abea484e2b14b52ebd6fb457438685 100644 --- a/test/annexB/language/function-code/if-decl-else-decl-b-func-update.js +++ b/test/annexB/language/function-code/if-decl-else-decl-b-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-block-scoping.js b/test/annexB/language/function-code/if-decl-else-stmt-func-block-scoping.js index 2ca3560f09430185984fff54a9f44af00bcfdccf..959087683b6d2706602c758c92a23eabe6043ada 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-block-scoping.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-no-init.js index e1759e0c400efde355ebf78b6206e292801b034a..f4eb572093ce80e0ab14d1d3e96a5a795d8b667a 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -26,7 +26,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-update.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-update.js index a4a5c9017c6ede405e7fb7f60b5f4e6963555564..387562821d514a06a7b7c283cdcc86f14d63ee2c 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-no-init.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-no-init.js index 19854c83859d1f2c690e69945978bdf67ac7dfc2..0f2291bbf743c1119d92adca63ceac17843a9253 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-update.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-update.js index 9d4c2402b8523e86603a98cf5e7cfb1a3add9cba..6fb6b4e4d8a97c7bf53532b9a5f17e1288662226 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'inner declaration'; } else ; after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-no-init.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-no-init.js index 263ccf71b353047bf5fc1184676925f5aa58bf7d..733434feba88feeef3e5c79645aa3345c1345066 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-update.js b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-update.js index 45f78d63a956dc2db571d19585b18b3007df64dc..5164fbd08f62f4ef7c06a160b515a3d3b8ac8a9b 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-update.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'function declaration'; } else ; after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-init.js b/test/annexB/language/function-code/if-decl-else-stmt-func-init.js index df2810ad1c13335c42febb1dc198a1c87370b2dd..87489fc5694b55ec1030e1c43984ddf84e9ddc87 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-init.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-no-skip-try.js b/test/annexB/language/function-code/if-decl-else-stmt-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..98efe5c2bd46f3efbf391b0a1a92a28ef6399575 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-no-skip-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + if (true) function f() { return 123; } else ; + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-block.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..f224770b2950fa2eb3b3d5ed8f850f7ee752e777 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-block.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + if (true) function f() { } else ; + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-in.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..85412ae2786ef837c3c9f8bd8f1b39312eb920df --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-in.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + if (true) function f() { } else ; + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-of.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..067af6ba9cc756d864e9a05cc5dd2a7c3589dc42 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for-of.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + if (true) function f() { } else ; + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..293b33ab631299a8e6463d6661317a454494ac35 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-for.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + if (true) function f() { } else ; + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-switch.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..27a231f47dc98df13e87de0016b3283cae5f2952 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-switch.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + if (true) function f() { } else ; + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-try.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..10b78c6b3918837e712822424c0903095f48b57c --- /dev/null +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-try.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + if (true) function f() { } else ; + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js index 70a4460857aa99a4eae611b3e2ffecaf30395d40..a056e2a4e74111f2dad71ea0f8c4e03b483a954f 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-param.js b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-param.js index 7bb9920ac337fb0b040ce4fd82258884c42c50a5..4ec14a0c99716ebf981b2e083112167f0c4b7b64 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-skip-param.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-skip-param.js @@ -6,18 +6,18 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-else-stmt-func-update.js b/test/annexB/language/function-code/if-decl-else-stmt-func-update.js index ce503d4bf2f3ea2248f2b483630927faa837e4c8..77e26a3e88052a3c038eff76e3ea92b9b34fdc23 100644 --- a/test/annexB/language/function-code/if-decl-else-stmt-func-update.js +++ b/test/annexB/language/function-code/if-decl-else-stmt-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-no-else-func-block-scoping.js b/test/annexB/language/function-code/if-decl-no-else-func-block-scoping.js index eb427c14443ba3ea7042d1ecd954f79db61f26f8..a5c576a7f7dc8bec80c3af78ffcbda40cd0802f0 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-block-scoping.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement without an else clau esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-no-init.js index 78af90219ff9e7a288b8fd295597b86f551b61e7..929125e9da671f48a3c9d9e11d2a0c5920439c16 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -26,7 +26,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-update.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-update.js index 216da722ec9159f215d1446a010a0b31a52151e7..cb154a814e74ea8c37d9c654c15104d192366f3c 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement without an else cla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-no-init.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-no-init.js index 2b8caf34e350455216145d374d18b2976269f41d..46290da3285f3a6531392a3418c383d7cf68dd62 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-update.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-update.js index d4540ea796d7838c16ae9b699648804ef049f873..677916d064854ccdd48e8c23fb6efe8deb61257e 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'inner declaration'; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-no-init.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-no-init.js index ab93a31ca51ddfe600bc21652aa270325cf66ab9..f4261a330c15d8a5d5b94620c5222d6976a85da0 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-update.js b/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-update.js index 2ffe6a2f885036c1bb50ac6290617bfe2975f37b..67e6af6543800a8e90c0983e0b9665e271cdec13 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-update.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (true) function f() { return 'function declaration'; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-init.js b/test/annexB/language/function-code/if-decl-no-else-func-init.js index 5e44f92ef468283b557a1fdafb30763d280e3337..ad141fb186b5d28a39f8c3b058a59872cae5bc77 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-init.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/if-decl-no-else-func-no-skip-try.js b/test/annexB/language/function-code/if-decl-no-else-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..0a3b2d1daf85527699db326984f3a13b42137858 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-no-skip-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + if (true) function f() { return 123; } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-block.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..0ec0334d66ce6a5526bd7cf287a10973ec29a042 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-block.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + if (true) function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-in.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..0e44127e6b8a9a6634e54fbfbddf5bb8204b5237 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-in.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + if (true) function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-of.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..62966083c31a547707f50309ff6454b4f3519c8b --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for-of.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + if (true) function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..ad23792493a6793565319469c0c3f34178569aed --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-for.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + if (true) function f() { } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-switch.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..8c85708fe80b04f5c12ba8215922bd432a938be4 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-switch.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + if (true) function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-try.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..bcc320805ebf0676f8c306f5bbf8a7a852111628 --- /dev/null +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err-try.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + if (true) function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err.js index b0c122b1eb65693db1b5d3b058be35b67304dec4..d9bee435bcf7e12de2a271a6082d1909f545de50 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-no-else-func-skip-param.js b/test/annexB/language/function-code/if-decl-no-else-func-skip-param.js index 3afe5d9045cc1279403dcbc2a6a5ac7566402c2b..22a3037aba1a4ae3cc598f83f5746b0ae8fa3aa9 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-skip-param.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-skip-param.js @@ -6,18 +6,18 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-decl-no-else-func-update.js b/test/annexB/language/function-code/if-decl-no-else-func-update.js index 3c4dd8917397d65058328ef8de4941c529cd55b9..b509d4b2223a7d2e551be46197fcd17d2d1eff2a 100644 --- a/test/annexB/language/function-code/if-decl-no-else-func-update.js +++ b/test/annexB/language/function-code/if-decl-no-else-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-block-scoping.js b/test/annexB/language/function-code/if-stmt-else-decl-func-block-scoping.js index 7eb97f3fe24a3f3f139f48e518e4119735dbc83e..49d992e6c450d6e5e24631fa79c10cd04e3ced0e 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-block-scoping.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-no-init.js index 8bbece4187cc26dd782df8aed03e26eca7c8bdff..d2d4dda89b589f440697d502af4a91b41399fb61 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -26,7 +26,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-update.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-update.js index 5b55034ea8650801de09e013b0730bcbcc55cba4..10ee54183ada6c0f578cf3ef4cc373a0ab91fdc6 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-block-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-no-init.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-no-init.js index 7cd43d46aa00293b29e3c6852ed3d700f8fe2067..51bb9cc632b9d17f126b873f919f892904050125 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-update.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-update.js index 50281dbf2320bbe2cb5da285cdd78ffcaa0064f9..43592e97b8688be0278be22076083193036d39cd 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-fn-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (false) ; else function f() { return 'inner declaration'; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-no-init.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-no-init.js index fe17be151f34d0d522ace6c2ef519df21d5a5765..acee159a641bbfbeb9221750e17c46e363d14c0c 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-update.js b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-update.js index c3bdc273d11c53155067e7146185287bdfb0e397..c3c544b6e03611199facca79c14a043aadbda3e0 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-update.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-exsting-var-update.js @@ -6,18 +6,18 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -38,7 +38,7 @@ var after; if (false) ; else function f() { return 'function declaration'; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-init.js b/test/annexB/language/function-code/if-stmt-else-decl-func-init.js index 29530261a24bcc504a902ee2b312311499a45795..54899d952d65e0bfe4035314fe2d641db48d3173 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-init.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-init.js @@ -6,18 +6,18 @@ description: Variable binding is initialized to `undefined` in outer scope (IfSt esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-no-skip-try.js b/test/annexB/language/function-code/if-stmt-else-decl-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..e60cd6c01270aa028dc3e8a5acbc47adbb4b04f1 --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-no-skip-try.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + if (false) ; else function f() { return 123; } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-block.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..1ab39012a9d6f38d0620654c2613f823b6cbe84a --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-block.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + if (false) ; else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-in.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..cb32a7911d30340f88535957fe1df3d9f9456a69 --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-in.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + if (false) ; else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-of.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..7c569d66b8510c2c5e626cb75390ad426e1bb3b7 --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for-of.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + if (false) ; else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..3c228755cbf922d653c7651763d60d866f689991 --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-for.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + if (false) ; else function f() { } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-switch.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..aaa3de9a60db3def1fc100e85be95b8fb8defbb3 --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-switch.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + if (false) ; else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-try.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..ec03e33785409c0bf584594ff3abff12966806ca --- /dev/null +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-try.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in function scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + if (false) ; else function f() { } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js index 602173926dc273da2c2d8d38f0f18562df2ba913..415f55df8c1a52af532462c46dc350cb8f4ee5ad 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-param.js b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-param.js index 7c468063523f1e76a35b829a06ccdd68b4ea6a27..561a6f97299313db84fa50004347df9d3acba9cd 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-skip-param.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-skip-param.js @@ -6,18 +6,18 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/if-stmt-else-decl-func-update.js b/test/annexB/language/function-code/if-stmt-else-decl-func-update.js index 249e1dab37fcb1c7b4e8a9107ca2a382827aa802..2f860bcd48ed3d4199a9e17f81fca14650e42cc4 100644 --- a/test/annexB/language/function-code/if-stmt-else-decl-func-update.js +++ b/test/annexB/language/function-code/if-stmt-else-decl-func-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/switch-case-func-block-scoping.js b/test/annexB/language/function-code/switch-case-func-block-scoping.js index 8531e36f9e4573b337d21e1e028515dd06361e5a..3ef3c6b9957ac36a9be4749f3996b2b546ebc43c 100644 --- a/test/annexB/language/function-code/switch-case-func-block-scoping.js +++ b/test/annexB/language/function-code/switch-case-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Function declaration in the `cas esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/switch-case-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/switch-case-func-exsting-block-fn-no-init.js index 0a9abd835a8cc297999b7fa98c274b6ad893bf5f..b6dce70b67a157b2c640541ae8b5b2564cc5bcc5 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Function d esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -17,7 +17,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/switch-case-func-exsting-block-fn-update.js b/test/annexB/language/function-code/switch-case-func-exsting-block-fn-update.js index fd243e30403932bc5051f80a19cfeb22527a73f4..32c2afffc7609a41ccdc5ee2ccf6f32cb9c8b53b 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Function declaration in the `ca esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/switch-case-func-exsting-fn-no-init.js b/test/annexB/language/function-code/switch-case-func-exsting-fn-no-init.js index a6e61c52d39f25fbb97dbcafdb4b7eaad3723c14..c97bd86cb728404e19e980353230900389ee81c8 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/switch-case-func-exsting-fn-update.js b/test/annexB/language/function-code/switch-case-func-exsting-fn-update.js index 98babd38da6d0c57409425c85a5f4761f400affb..c613709a0c3780847bbd0b25c98d0a656b2999a4 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -32,7 +32,7 @@ var after; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/switch-case-func-exsting-var-no-init.js b/test/annexB/language/function-code/switch-case-func-exsting-var-no-init.js index 4dcf01ea87bf3aa3b8bc72181e4db0ed2583faf5..e875973f8792aa71fde3f4910f82a4bacca3186d 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/switch-case-func-exsting-var-update.js b/test/annexB/language/function-code/switch-case-func-exsting-var-update.js index 67e0b9858f148ebb024200349057568a18ae0b0b..77a459b6abb7101159b6484422d5b2f505e5d2c8 100644 --- a/test/annexB/language/function-code/switch-case-func-exsting-var-update.js +++ b/test/annexB/language/function-code/switch-case-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -32,7 +32,7 @@ var after; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/switch-case-func-init.js b/test/annexB/language/function-code/switch-case-func-init.js index 7f277a4802a2a62ada8937bf06fa0ee53b75ee37..8db0353444b111545340a30748bd3ff0932d5f9e 100644 --- a/test/annexB/language/function-code/switch-case-func-init.js +++ b/test/annexB/language/function-code/switch-case-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Func esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/switch-case-func-no-skip-try.js b/test/annexB/language/function-code/switch-case-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..72cc559ba050866ab78472ce428735e91ee16aad --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-no-skip-try.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/switch-case.template +/*--- +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) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + switch (1) { + case 1: + function f() { return 123; } + } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-block.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..1e14e1bcfcc2e63a2f94098dc91582ff4531dbb5 --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-block.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Function declaration in the `case` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + switch (1) { + case 1: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-for-in.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..fade510ff9f58f17b58c10ab001c60b98b781974 --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-for-in.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + switch (1) { + case 1: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-for-of.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..f2c15af9aa988df24a4a410e54414ab85f1e78b9 --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-for-of.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + switch (1) { + case 1: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-for.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..7952a91549ddb5fa1c3e6236de184940c1dae5f0 --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-for.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Function declaration in the `case` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + switch (1) { + case 1: + function f() { } + } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-switch.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..3b5e9a81e8ccc57c9fadda86a1321ef108a2d21a --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-switch.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Function declaration in the `case` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + switch (1) { + case 1: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err-try.js b/test/annexB/language/function-code/switch-case-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..e4be091f823dc1ca6c1e76ce7f54260832242849 --- /dev/null +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err-try.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/switch-case.template +/*--- +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) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + switch (1) { + case 1: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-case-func-skip-early-err.js b/test/annexB/language/function-code/switch-case-func-skip-early-err.js index 851601c7ed2976c507038a720858723d807c21b2..e74ee0b39d3c9f1efed0ab1fd7b667b2af0e7291 100644 --- a/test/annexB/language/function-code/switch-case-func-skip-early-err.js +++ b/test/annexB/language/function-code/switch-case-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/switch-case-func-skip-param.js b/test/annexB/language/function-code/switch-case-func-skip-param.js index 9d55de4cdf9601eb255b161eae33e842a4161579..9fada066dc9f77aa5ba490453513b82069d301c3 100644 --- a/test/annexB/language/function-code/switch-case-func-skip-param.js +++ b/test/annexB/language/function-code/switch-case-func-skip-param.js @@ -6,9 +6,9 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/switch-case-func-update.js b/test/annexB/language/function-code/switch-case-func-update.js index 123a76be5101de0d41d6197d8910d756274f5214..cf4ece074c0dbd24d05bb0bce71f754bdfcddd7c 100644 --- a/test/annexB/language/function-code/switch-case-func-update.js +++ b/test/annexB/language/function-code/switch-case-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Function de esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/switch-dflt-func-block-scoping.js b/test/annexB/language/function-code/switch-dflt-func-block-scoping.js index bd11fd6458869537854915f2fe638befe779437a..af2ce68612a8a76f65b31677cde1f82c8161f301 100644 --- a/test/annexB/language/function-code/switch-dflt-func-block-scoping.js +++ b/test/annexB/language/function-code/switch-dflt-func-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Funtion declaration in the `defa esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-no-init.js b/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-no-init.js index 578b91adfd3adf7eec1222c51359be104f583087..e08bb54701680aa87a69345202ad6a1deed3251a 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-no-init.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Funtion de esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] @@ -17,7 +17,7 @@ var init; (function() { init = f; - + { function f() {} } diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-update.js b/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-update.js index 068e06712952ecd39a419425729edde9974766a4..6fe324509df2d10839841020dee0df2fbebf97ba 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-update.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-block-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated (Funtion declaration in the `def esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-fn-no-init.js b/test/annexB/language/function-code/switch-dflt-func-exsting-fn-no-init.js index af4f080d20f2ea03fcb204ff8d18551f6f6aa8c6..495e43c3a2e305d73e98dec5cd303d3c1dc2f2c3 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-fn-no-init.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-fn-update.js b/test/annexB/language/function-code/switch-dflt-func-exsting-fn-update.js index 7ed94848a005aeec0fce8043a5a1ee572641af87..bfe9f7f2aed69d4b84506211c2afdf0893ad7e9c 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-fn-update.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-fn-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -32,7 +32,7 @@ var after; } after = f; - + function f() { return 'outer declaration'; } diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-var-no-init.js b/test/annexB/language/function-code/switch-dflt-func-exsting-var-no-init.js index 66df544bf1215886ea21166fddac7400f553be9f..ec3037b4d4c4b11dba88af0fc4e3da446209b9b0 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-var-no-init.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then [...] diff --git a/test/annexB/language/function-code/switch-dflt-func-exsting-var-update.js b/test/annexB/language/function-code/switch-dflt-func-exsting-var-update.js index 641b8ea0de23ef15cfe076a1089c076a81152b17..2398ae941487bfd2cd51bbcc3bee2a1061adee0e 100644 --- a/test/annexB/language/function-code/switch-dflt-func-exsting-var-update.js +++ b/test/annexB/language/function-code/switch-dflt-func-exsting-var-update.js @@ -6,9 +6,9 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in @@ -32,7 +32,7 @@ var after; } after = f; - + var f = 123; }()); diff --git a/test/annexB/language/function-code/switch-dflt-func-init.js b/test/annexB/language/function-code/switch-dflt-func-init.js index ddd4d5c5c24a6a0109552212902dc12f69bc2075..3884b9619c557bdc82b43ba54c166b8a8a68410f 100644 --- a/test/annexB/language/function-code/switch-dflt-func-init.js +++ b/test/annexB/language/function-code/switch-dflt-func-init.js @@ -6,9 +6,9 @@ description: Variable binding is initialized to `undefined` in outer scope (Funt esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 2. If instantiatedVarNames does not contain F, then a. Perform ! varEnvRec.CreateMutableBinding(F, false). diff --git a/test/annexB/language/function-code/switch-dflt-func-no-skip-try.js b/test/annexB/language/function-code/switch-dflt-func-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..def3d3b83c36bd89041337085bd7325b03b9184b --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-no-skip-try.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-no-skip-try.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' + ); + + try { + throw null; + } catch (f) { + + switch (1) { + default: + function f() { return 123; } + } + + } + + assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' + ); + assert.sameValue(f(), 123); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-block.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..22a6686f28349df6bf9ba88b64f0342a2ae20f36 --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-block.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-block.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + { + let f = 123; + + switch (1) { + default: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-in.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..7e40ba396d7e947989c3ca67e43afbf3551927fd --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-in.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-in.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f in { key: 0 }) { + + switch (1) { + default: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-of.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..43079639a4bbaa052f303f81b45a23ee3a399e4a --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for-of.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for-of.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f of [0]) { + + switch (1) { + default: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..d091870bf5f8f68bab3578c387755e21a07ce939 --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-for.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-for.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + for (let f; ; ) { + + switch (1) { + default: + function f() { } + } + + break; + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-switch.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e0e1eeeaaf7e72c078c0a777d4bfb1b44fb8c5 --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-switch.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-switch.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of BoundNames of argumentsList, then + [...] +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + switch (0) { + default: + let f; + + switch (1) { + default: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err-try.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..d393cf4317386f365f11163fba1f42c5ab7c977d --- /dev/null +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err-try.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/func-skip-early-err-try.case +// - src/annex-b-fns/func/switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in function scope) +esid: sec-web-compat-functiondeclarationinstantiation +es6id: B.3.3.1 +flags: [generated, noStrict] +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + [...] + 2. If instantiatedVarNames does not contain F, then + a. Perform ! varEnvRec.CreateMutableBinding(F, false). + b. Perform varEnvRec.InitializeBinding(F, undefined). + c. Append F to instantiatedVarNames. + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ + +(function() { + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created prior to evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' + ); + + try { + throw {}; + } catch ({ f }) { + + switch (1) { + default: + function f() { } + } + + } + + assert.throws(ReferenceError, function() { + f; + }, 'An initialized binding is not created following evaluation'); + assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' + ); +}()); diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-early-err.js b/test/annexB/language/function-code/switch-dflt-func-skip-early-err.js index e308c8347f767cb9c4cf082dff1aa044742f4bb8..daeaae661dd9fd41f2e94c72bbb14bf7459795cc 100644 --- a/test/annexB/language/function-code/switch-dflt-func-skip-early-err.js +++ b/test/annexB/language/function-code/switch-dflt-func-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/switch-dflt-func-skip-param.js b/test/annexB/language/function-code/switch-dflt-func-skip-param.js index b6ade21098d72b1cf4ce3a4ddecdcc4749c48b8b..81acc0e190e7862b3da93fdb490f849ffd5f3258 100644 --- a/test/annexB/language/function-code/switch-dflt-func-skip-param.js +++ b/test/annexB/language/function-code/switch-dflt-func-skip-param.js @@ -6,9 +6,9 @@ description: Extension not observed when there is a formal parameter with the sa esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] ii. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for diff --git a/test/annexB/language/function-code/switch-dflt-func-update.js b/test/annexB/language/function-code/switch-dflt-func-update.js index cc7ed2307867ccd116040ddd967b64fc46ac696c..49bcbcdb0ef51788948015946c70e4db937d60f0 100644 --- a/test/annexB/language/function-code/switch-dflt-func-update.js +++ b/test/annexB/language/function-code/switch-dflt-func-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Funtion dec esid: sec-web-compat-functiondeclarationinstantiation es6id: B.3.3.1 flags: [generated, noStrict] -info: > +info: | B.3.3.1 Changes to FunctionDeclarationInstantiation - + [...] 3. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/block-decl-global-block-scoping.js b/test/annexB/language/global-code/block-decl-global-block-scoping.js index 9d6da0ed9d8b8873d4fcfcb5af07dcccb18bb0b3..ad02c4f151a14cb430646edb75f9b5b979146eca 100644 --- a/test/annexB/language/global-code/block-decl-global-block-scoping.js +++ b/test/annexB/language/global-code/block-decl-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Block statement in the global sc esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/block-decl-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/block-decl-global-exsting-block-fn-no-init.js index c04974a4fab6c25419973f2ba0bab540c45b645d..fdf140ab32b8ca5853004f2988ebc244a1d529d9 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Block stat esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/block-decl-global-exsting-block-fn-update.js b/test/annexB/language/global-code/block-decl-global-exsting-block-fn-update.js index b8f9ac9044ef5e29ac6c585395150de5c4c5f133..a3d5165302b4af466a4daecec65d52acafdb2e85 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-block-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated (Block statement in the global s esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/block-decl-global-exsting-fn-no-init.js b/test/annexB/language/global-code/block-decl-global-exsting-fn-no-init.js index b97a637fb7562ec6ce635293d33f5417b5c5c0dd..e72291ec1a95695ce0c2044fbff935a2634d0f59 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in the g esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/block-decl-global-exsting-fn-update.js b/test/annexB/language/global-code/block-decl-global-exsting-fn-update.js index c6ffe4683f9994de73292c3ab6bfdcb1f7b2377c..9e40ee579d9d51e6df669f1716b4a54eeb8e95dc 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/block-decl-global-exsting-var-no-init.js b/test/annexB/language/global-code/block-decl-global-exsting-var-no-init.js index 701409039d7bcb961c2d25e49a52498f2c9048a1..4e8b7fe68562a23c567c62b66b8559dc12621a9b 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Block statement in the g esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/block-decl-global-exsting-var-update.js b/test/annexB/language/global-code/block-decl-global-exsting-var-update.js index c8a26d879bbdf27c195eae2f46a8d02a68bdfb73..de08e280310b0fd82f3d40f19a958e024c13ca21 100644 --- a/test/annexB/language/global-code/block-decl-global-exsting-var-update.js +++ b/test/annexB/language/global-code/block-decl-global-exsting-var-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Block stat esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/block-decl-global-init.js b/test/annexB/language/global-code/block-decl-global-init.js index 6b1975848614c577ab19ea9fd07da097410766b0..e0563878ceec15a7805ad2305bfd56c0d5419dc0 100644 --- a/test/annexB/language/global-code/block-decl-global-init.js +++ b/test/annexB/language/global-code/block-decl-global-init.js @@ -7,15 +7,15 @@ esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/block-decl-global-no-skip-try.js b/test/annexB/language/global-code/block-decl-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..b0803e9184c9914a56f423ecdb4d6c36eb5e404e --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-no-skip-try.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +{ + function f() { return 123; } +} + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-block.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..fc8be9749c9d1a7926e5257e212c6fbae9377dc0 --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-block.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +{ + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-for-in.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..b9f7cae410fb07031d566c7fe16afaefeb50349a --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-for-in.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +{ + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-for-of.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..168f20d8885dd6bd607de216681f85001af1dab3 --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-for-of.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +{ + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-for.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..edaf893b43c44be5717447eaeb44f2ccffc99fd4 --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-for.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +{ + function f() { } +} + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-switch.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..c2796bfcea3f3fc9b2fba66208e971265ca3b95c --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-switch.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +{ + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err-try.js b/test/annexB/language/global-code/block-decl-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..464f23bd5d4b4cb214593843a61a114cc44e60e7 --- /dev/null +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/block.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Block statement in the global scope containing a function declaration) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +{ + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/block-decl-global-skip-early-err.js b/test/annexB/language/global-code/block-decl-global-skip-early-err.js index bc17896ad617a9529e9b55fdefdcd6da354e345b..876dedcafce97de3134846cb27f3e71f8d905062 100644 --- a/test/annexB/language/global-code/block-decl-global-skip-early-err.js +++ b/test/annexB/language/global-code/block-decl-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/block-decl-global-update.js b/test/annexB/language/global-code/block-decl-global-update.js index 39a96bb28e44ab842f18b568c8205194f4d6cc60..f8897d046d925b9bc85281b3cb21ac4d4bec0e63 100644 --- a/test/annexB/language/global-code/block-decl-global-update.js +++ b/test/annexB/language/global-code/block-decl-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Block state esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-block-scoping.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-block-scoping.js index ad48231f478925ce159bc6b325758915bbe2bd44..b4378f0e3107c50e89d954d2d4d5b13422e099fe 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-block-scoping.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-no-init.js index c741c75ff0ade1e668fef832e4c76e23bac76424..8e6483f2bf2e546fdc5e56276f748e3339c7c6a5 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-update.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-update.js index 9244ec92050682ceec0261e0ae8036fa3ba475ed..035c47d0ab37d6726294c2edabe236606a4d7856 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-block-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-no-init.js index 9de2fcb7e54ddd45829b7727f0e9123a231bb9e4..981eaf54589ec9bc3c3d8503f9222a0a72254ba6 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-update.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-update.js index 7926b9a6007e6e46d8d387404335bb6fd377b3a6..a0c947e85573d88a27c14c1fd0399ee359cd1930 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-no-init.js index 7f3c8a4c3379775475c0e3164ec31026be6d368a..354f1d8c01357677942d6e9df00193aa274e625d 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-update.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-update.js index 1f0a475a094fcc20f9917e4b553461164929531f..b6a6e8355c031ddcae3d4b944c706317a937a1a1 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-exsting-var-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-init.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-init.js index 3c699a1bb7450e802adce208f79e1da86a8e0c90..496b989e24b9163500c8bed2ae129bf2364f53f7 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-init.js @@ -7,24 +7,24 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-no-skip-try.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..1e48f34147dff066ea059d3006d6aecb6150b0e8 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-no-skip-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +if (true) function f() { return 123; } else function _f() {} + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-block.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..9ad0b5024cd3197248e3e9c46881da774868cf49 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-block.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +if (true) function f() { } else function _f() {} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-in.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..fdfc018f2f16cf24e3bc57dbf222a2fbfc815e11 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-in.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +if (true) function f() { } else function _f() {} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-of.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..7d79e43a8f97aab95061789d26fcf110817886e5 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for-of.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +if (true) function f() { } else function _f() {} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..21478ed89cd09726bfd4216fad0258c8cc6db48b --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-for.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +if (true) function f() { } else function _f() {} + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-switch.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..90fbd0743b84871020f89738551abfb7e81adddc --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-switch.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +if (true) function f() { } else function _f() {} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-try.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..39cd68b0d268ca204616fcc9dc523356031150fb --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-try.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/if-decl-else-decl-a.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +if (true) function f() { } else function _f() {} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js index 4aa07ae49560e3df3ab5b6a99eaf30983142c062..18dbd5d1fabeb38e6084a39fcaf0942118e0d5b9 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/if-decl-else-decl-a-global-update.js b/test/annexB/language/global-code/if-decl-else-decl-a-global-update.js index 75fba6b8084b0197f9135d7731dca2a617242ed9..7d1b533ed2e1e9040e086d69b2d6b59b5777ab47 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-a-global-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-a-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-block-scoping.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-block-scoping.js index 9bfc089f006a1f4007e814da09e117bf8b8d0012..05fdc435ea90b1d6fd08c1790ce71e70b1522e70 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-block-scoping.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-no-init.js index dcb62e438f0f7c374d32ed080042c3efb31ab6b8..101b1a33488df871e3e5ab20f7ecf9c0b6c1af60 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-update.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-update.js index 50ccbc815d054ab53e2b24ab3b7002e8d3299feb..5cfb462038811e559a5d32e864e16ba3789449a4 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-block-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-no-init.js index 45c6e7da580efece80ef6030fe845b529741a034..61253c7279f06104e5cd700fad2b2c68963a9bdb 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-update.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-update.js index 7feba43d56bed7e28dddb38b8c0abe8f5e5788a8..6fc29662ca9b9b1c2359a451f335c29d31e9f76b 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-no-init.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-no-init.js index 94c406ba91d9f2313f2b6694fb08489d9fdc3107..d9e07d119934ed38780d2f9e7afd8c5f2d29938d 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-update.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-update.js index 17171368822200f2dc9fe5d48e8d4168f4502d0c..b9bd101a61265053f1addc6ff88c011f8ad75c98 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-exsting-var-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-init.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-init.js index 4be847d386650e4518ab2842195031b41b498bf8..0bb7e9b49b9df0d611f0a855dc20946e64ee205b 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-init.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-init.js @@ -7,24 +7,24 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-no-skip-try.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..aafb04ea20edcb9c3de6fc2290c5873df2c14019 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-no-skip-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +if (false) function _f() {} else function f() { return 123; } + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-block.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..35366c4e5e49be8d258219c4adf7d3442f920777 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-block.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +if (false) function _f() {} else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-in.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..2d383d2aa258d8c89dbadf9cd6164df10172dbaf --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-in.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +if (false) function _f() {} else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-of.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..1fc3b6551b99477231bbb563ac038501a2ea3f92 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for-of.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +if (false) function _f() {} else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..1392138f262d6007a89914c26584a322cb19e281 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-for.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +if (false) function _f() {} else function f() { } + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-switch.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..2e304324f6220e445e10e39bca8db9ea5f98cc24 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-switch.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +if (false) function _f() {} else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-try.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..061a0b33da95111956bf86290f450b7f3a5ee270 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-try.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/if-decl-else-decl-b.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in both statement positions in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +if (false) function _f() {} else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js index bb2cbc80cf849a79ddfa299898ef291c8848a6dd..310271675e7d6187f8534b5247c24968e1f74c4b 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/if-decl-else-decl-b-global-update.js b/test/annexB/language/global-code/if-decl-else-decl-b-global-update.js index b47bf108185c9ff24e062b302d808ecba2855a66..7b00ccb7e2859df9771ab7eb90fd7c4bb32ad801 100644 --- a/test/annexB/language/global-code/if-decl-else-decl-b-global-update.js +++ b/test/annexB/language/global-code/if-decl-else-decl-b-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-block-scoping.js b/test/annexB/language/global-code/if-decl-else-stmt-global-block-scoping.js index 4df9e34aab84059156c63bc26fb25d0ccf547a6c..323e83cf39cfbba2baf4233bb892e6661eb77459 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-block-scoping.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-no-init.js index fb9bc6a8b014934fdd92c893718b8294c33cc2a6..5af53e99add81cc49d0696f5362b3ef4fa639d9b 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-update.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-update.js index beb43958b2763bd64efd006b7dc02277207d965e..80479e8c12dd752e3a0de2a36d1048270bc0ea23 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-block-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-no-init.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-no-init.js index 058c1a6eeb6619bf106c35b017396534bfb3d8bc..4574a8be28e23e3ee9e106fabea7e2f032b3689c 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-update.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-update.js index dcd777e24189f602ec4aca103c6ab491bebb153e..4971e6247d6d124ebb09191e059f553bdd998bd1 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-no-init.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-no-init.js index 4d9c35e522301c2d004995f62791317011287c97..45d7d6be9e6ba4107b472f3a94b804d2f162c0af 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-update.js b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-update.js index c59d61630ad8a85a3afbaec1c0791b820281c20a..e1e5d8303d1afb303f8feb5c5e49a83edd9dd8e2 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-update.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-exsting-var-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-init.js b/test/annexB/language/global-code/if-decl-else-stmt-global-init.js index d45d6a57413c6a99d66a12756fc844da56bf8bba..ed41226240880f2f22052e04d6249b23d1615c6f 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-init.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-init.js @@ -7,24 +7,24 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-no-skip-try.js b/test/annexB/language/global-code/if-decl-else-stmt-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..3cd30e4bebbe4951b0de86691bfbe1b214192a04 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-no-skip-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +if (true) function f() { return 123; } else ; + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-block.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..cd1b644cc6c4ad20fa01ed4a07a51dd3fc183c17 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-block.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +if (true) function f() { } else ; + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-in.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..f8bc7f4e12faabc147150551706c3c0b584a5314 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-in.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +if (true) function f() { } else ; + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-of.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..be5688a0fabab98ff398b2590dc3e7c561a2202c --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for-of.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +if (true) function f() { } else ; + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..660b172c49be4009bd00f72838542269d8c9d9e4 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-for.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +if (true) function f() { } else ; + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-switch.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..359b3dda70852586e7cd4bd70c933aee19f9391e --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-switch.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +if (true) function f() { } else ; + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-try.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..317d97f69a4fe8e4a15b2fbac2cb7c22d4c1a067 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-try.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/if-decl-else-stmt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the first statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +if (true) function f() { } else ; + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js index d31ad7929b76e4a90a8514d307fbdaa3d636f7aa..e57fff13fd45d5f9bc6d73319bdd12be2fe30f8d 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/if-decl-else-stmt-global-update.js b/test/annexB/language/global-code/if-decl-else-stmt-global-update.js index 1d2248520194fb04e2fb4e2c6bb69d2525ac9a0f..a973da9efe76884d74562af92392e58507764d96 100644 --- a/test/annexB/language/global-code/if-decl-else-stmt-global-update.js +++ b/test/annexB/language/global-code/if-decl-else-stmt-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/if-decl-no-else-global-block-scoping.js b/test/annexB/language/global-code/if-decl-no-else-global-block-scoping.js index 230d2ff715c25d0ce7e5fa399aa010fe1e742f91..2291a7ba6b6f3e633bdae5b7cf82c15e3404617f 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-block-scoping.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement without an else clau esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-no-init.js index 047739d15c3f9f6c328d8f6a89702c03ef413f30..f1557a7042a0f93db3eec00408cede3fbcb1b144 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-update.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-update.js index dea0feace0ab8fcf50b5473a0cbd70f55f602413..4030c79b24a3e47b6411d2362c081bc9e5f1c7ae 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-block-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated (IfStatement without an else cla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-no-init.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-no-init.js index b491d2f15d5e24435e044fb23c4b2914326d2177..7f301eb6cebb95fafdbf9b4fd686890477007876 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-update.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-update.js index a5e2bd9e81c0ceb1fd3b08337e643dc01e106dfb..9db864ecd5d3110e55f9ece358fec7e3ce328333 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-no-init.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-no-init.js index b52cdb3251e18441fb2eb7c650237531781db70a..b7380a411a9aec6af589968cf4a188058222383b 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement without an e esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-update.js b/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-update.js index cebaba33c218c5716be4106349cdc7cab50dee14..0e61b8a0ba51a4470eaba990caedb9d858a9ad92 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-update.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-exsting-var-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-decl-no-else-global-init.js b/test/annexB/language/global-code/if-decl-no-else-global-init.js index cdfc1f25258beeb1335310560d8e120c0e7a0421..85748a57c984beaf50bbb6770eec8d7b95ea35b9 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-init.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-init.js @@ -7,24 +7,24 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-no-skip-try.js b/test/annexB/language/global-code/if-decl-no-else-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..20a157b8ff16f6e0b6c1bd525d3e4703bd7277a9 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-no-skip-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +if (true) function f() { return 123; } + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-block.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..dded5878b1c56f3f4a5aad3e5429a8acc0e4f6e0 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-block.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +if (true) function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-in.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..45fa7582143d5fd3a9229627d337840d4b80548e --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-in.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +if (true) function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-of.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..592d4c059c2325ec110027fe726010978e63f975 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for-of.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +if (true) function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..2be206cc7ffaf9f356e007da7f6c5077789ab8c8 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-for.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +if (true) function f() { } + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-switch.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..f7b6785468f2b514642f08838d570b0febe7b303 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-switch.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +if (true) function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-try.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..d27824bdd235772fb1f558bad64a40b4a77b9a82 --- /dev/null +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err-try.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/if-decl-no-else.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement without an else clause in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +if (true) function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err.js b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err.js index 4c6d54bf146a7f97979b3b3107e5cc634b7f9b73..76f0c07bc47321c207c8e8c43bbdb99fe3e6c872 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/if-decl-no-else-global-update.js b/test/annexB/language/global-code/if-decl-no-else-global-update.js index b1944aa4acab0013d053e281f72a7a0a003182ff..f036b627219bab1fb1e81ebb68d4dc658cf87dca 100644 --- a/test/annexB/language/global-code/if-decl-no-else-global-update.js +++ b/test/annexB/language/global-code/if-decl-no-else-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-block-scoping.js b/test/annexB/language/global-code/if-stmt-else-decl-global-block-scoping.js index 410048451c787c9a9c15752c0532a415bac5572d..7e94de84a03209e8724ff28a2d6498bd2659fba3 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-block-scoping.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-block-scoping.js @@ -6,18 +6,18 @@ description: A block-scoped binding is created (IfStatement with a declaration i esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -25,7 +25,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-no-init.js index 02a2dbfe775c3a2705b57e0dc65e061ed9fb9161..b6b68c32ee33a6ee2388bf4fd1beef7bfb4e7565 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-no-init.js @@ -6,18 +6,18 @@ description: Does not re-initialize binding created by similar forms (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-update.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-update.js index 58826a4a902a90c0e91a12be9deb3f64b336a91a..463f1c8483efff97182704a3e539c18de0ea33ac 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-block-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated (IfStatement with a declaration esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-no-init.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-no-init.js index a7e51e7e41c5dd38691b213abbf6c1d7fac8008a..9f8764eeb75aefcc0aa7acedd63607843a4997b1 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-update.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-update.js index 19ab633e8073ec4525ac69156f0f0b2482330dd0..f365f9bd0d5b08264f9225f30868a1a73dfc92f2 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-fn-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-no-init.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-no-init.js index ac3ba87c36a46d538e0dbda59285c40da68eabdb..a2196d23b3f33a3d6af85ce679745241bef391dc 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-no-init.js @@ -6,18 +6,18 @@ description: Existing variable binding is not modified (IfStatement with a decla esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-update.js b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-update.js index d6e3960d1072b8614caf1d242f0bb95814f462c5..7e5dca1d47380c531a9118f23525f9b73a3e48ea 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-update.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-exsting-var-update.js @@ -6,22 +6,22 @@ description: Variable-scoped binding is updated following evaluation (IfStatemen esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-init.js b/test/annexB/language/global-code/if-stmt-else-decl-global-init.js index 95d8f20d73befaf0939501f762f40d8d1e765b09..c4b27987c19d71b627e4d270e1f8f302f8b54db6 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-init.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-init.js @@ -7,24 +7,24 @@ esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-no-skip-try.js b/test/annexB/language/global-code/if-stmt-else-decl-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..8d785de1b6c8275e8eac8c07c8d3f6b003ec27af --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-no-skip-try.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +if (false) ; else function f() { return 123; } + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-block.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..22f52e1610dd12d920635e548f6534277c5199a6 --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-block.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +if (false) ; else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-in.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..722aaf4b065b9d4a3014a15fcb7c7fb9841e26e6 --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-in.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +if (false) ; else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-of.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..7bc26e68f2db117e7b1a2b22e00f73ef695ff248 --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for-of.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +if (false) ; else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..6fd97554a1567d668de72def7d10ad9e6a5f6eae --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-for.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +if (false) ; else function f() { } + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-switch.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..0b4797146c3313fc7b31584f0e66c6b21c9a84d2 --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-switch.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +if (false) ; else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-try.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..f3e9744105bd6d9211835430dd08ad9fadbfb8c8 --- /dev/null +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-try.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/if-stmt-else-decl.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (IfStatement with a declaration in the second statement position in the global scope) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +es6id: B.3.4 +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +if (false) ; else function f() { } + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js index d255ea2388a59a65bd2cf3a5593505224e134a73..1e3600ad461ad8e45648213fb051e6ad2b4e8b2a 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js @@ -6,18 +6,18 @@ description: Extension not observed when creation of variable binding would prod esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/if-stmt-else-decl-global-update.js b/test/annexB/language/global-code/if-stmt-else-decl-global-update.js index 4f1cefd9be95bd922acc548ffe619a3d2c562a6d..298a7ab0142b699cdaf037a39184e9e9abe72ca9 100644 --- a/test/annexB/language/global-code/if-stmt-else-decl-global-update.js +++ b/test/annexB/language/global-code/if-stmt-else-decl-global-update.js @@ -6,18 +6,18 @@ description: Variable binding value is updated following evaluation (IfStatement esid: sec-functiondeclarations-in-ifstatement-statement-clauses es6id: B.3.4 flags: [generated, noStrict] -info: > +info: | The following rules for IfStatement augment those in 13.6: - + IfStatement[Yield, Return]: if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] - + B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/switch-case-global-block-scoping.js b/test/annexB/language/global-code/switch-case-global-block-scoping.js index 46da5ea41230ccdc2a272cd44a22066090047e23..19dc84507a2bb4d7e824a4204b83b82b2f8d9a04 100644 --- a/test/annexB/language/global-code/switch-case-global-block-scoping.js +++ b/test/annexB/language/global-code/switch-case-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Function declaration in the `cas esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/switch-case-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/switch-case-global-exsting-block-fn-no-init.js index 37c65a208a3759a8dd5cbd5448cb234076a1f310..c2371e00c21ab60b7d94e5a88579fcd754f0525d 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Function d esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/switch-case-global-exsting-block-fn-update.js b/test/annexB/language/global-code/switch-case-global-exsting-block-fn-update.js index 1c08e1620604edd6c4e967ff6ec9915c75f82493..59bd335326d689d19000c31edaa89628c85750f6 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-block-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated (Function declaration in the `ca esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-case-global-exsting-fn-no-init.js b/test/annexB/language/global-code/switch-case-global-exsting-fn-no-init.js index 24e3901bb6753dbb0d9dde04534379262b24bc3d..1af1798de51b05c303a37d25af15894d0abb0016 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/switch-case-global-exsting-fn-update.js b/test/annexB/language/global-code/switch-case-global-exsting-fn-update.js index aa1442adf05c9d55da0f25dc6dba36dbec61de3e..07d516d6c83df5f117236659535da62e90e86beb 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-case-global-exsting-var-no-init.js b/test/annexB/language/global-code/switch-case-global-exsting-var-no-init.js index 30b588f75f0134a8035177167fad0de7299e02ae..34d65deb69c6351e7d3c96804e7e7a2ae4af1e51 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Function declaration in esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/switch-case-global-exsting-var-update.js b/test/annexB/language/global-code/switch-case-global-exsting-var-update.js index aca7c7d798f39681f418e3bea1904fe15a891edc..5019b0b1af5cffefc7b2467a9bb79ccff82cc1a3 100644 --- a/test/annexB/language/global-code/switch-case-global-exsting-var-update.js +++ b/test/annexB/language/global-code/switch-case-global-exsting-var-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Function d esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-case-global-init.js b/test/annexB/language/global-code/switch-case-global-init.js index 4efe60ba08243809b46c98ef858a25db6daf4bdd..38a3e928b43931b722ad92417695ae30ade31f3e 100644 --- a/test/annexB/language/global-code/switch-case-global-init.js +++ b/test/annexB/language/global-code/switch-case-global-init.js @@ -7,15 +7,15 @@ esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/switch-case-global-no-skip-try.js b/test/annexB/language/global-code/switch-case-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..26a8b6ee2dc045ca41ba5437305bf89bd74eb8f0 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/switch-case.template +/*--- +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 the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +switch (1) { + case 1: + function f() { return 123; } +} + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-block.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..aacd62aa8577291bc1c97447bd3a81d0c3363e23 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-block.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Function declaration in the `case` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +switch (1) { + case 1: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-for-in.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..cddc56bfff860af2dcb9a4f1f0dade5dda202289 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-for-in.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +switch (1) { + case 1: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-for-of.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..68c55d6a32c7b7b149a5dedb3a1b25094dd14a96 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-for-of.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Function declaration in the `case` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +switch (1) { + case 1: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-for.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..3b589bddbc99cc9b82d1bf213cfc7417c527fe37 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-for.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Function declaration in the `case` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +switch (1) { + case 1: + function f() { } +} + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-switch.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..3dc7e68442dab5633ffedb8aef4277f8e5e803ad --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-switch.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/switch-case.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Function declaration in the `case` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +switch (1) { + case 1: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err-try.js b/test/annexB/language/global-code/switch-case-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..fe9fcf2b50f7708646267ec84b13c4cf46927cb9 --- /dev/null +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/switch-case.template +/*--- +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 the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +switch (1) { + case 1: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-case-global-skip-early-err.js b/test/annexB/language/global-code/switch-case-global-skip-early-err.js index da95ca4bd2cda971e24289a6e82f41945106e194..5c55f0f0a9e358b0d32ffb484f13066176a246c5 100644 --- a/test/annexB/language/global-code/switch-case-global-skip-early-err.js +++ b/test/annexB/language/global-code/switch-case-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/switch-case-global-update.js b/test/annexB/language/global-code/switch-case-global-update.js index 72e0198281718129f544fbcf65ad160be36012f8..63f9b357fdbae60b80c5c6c9f66318886bb0fb04 100644 --- a/test/annexB/language/global-code/switch-case-global-update.js +++ b/test/annexB/language/global-code/switch-case-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Function de esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in diff --git a/test/annexB/language/global-code/switch-dflt-global-block-scoping.js b/test/annexB/language/global-code/switch-dflt-global-block-scoping.js index 0398137720d27b1494e5bcb9bac2fc5a7e5baafb..1d0fabbe0188a25ed5743cadef58bfd06526a8c4 100644 --- a/test/annexB/language/global-code/switch-dflt-global-block-scoping.js +++ b/test/annexB/language/global-code/switch-dflt-global-block-scoping.js @@ -6,9 +6,9 @@ description: A block-scoped binding is created (Funtion declaration in the `defa esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | 13.2.14 Runtime Semantics: BlockDeclarationInstantiation - + [...] 4. For each element d in declarations do a. For each element dn of the BoundNames of d do @@ -16,7 +16,7 @@ info: > [...] ii. Else, 2. Perform ! envRec.CreateMutableBinding(dn, false). - + b. If d is a GeneratorDeclaration production or a FunctionDeclaration production, then i. Let fn be the sole element of the BoundNames of d. diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-no-init.js b/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-no-init.js index 9f24e25627d1aef8534f3c0847a1e48abb62e82d..33d5844efc641944022bb6f0a61cb0a399bb617a 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-no-init.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-no-init.js @@ -6,9 +6,9 @@ description: Does not re-initialize binding created by similar forms (Funtion de esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-update.js b/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-update.js index 31ddc08fc520a6f6cacbdd9b92688d7c5f8af33f..08f6721561777e7a4200bb05d31de9b5aeb24067 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-update.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-block-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated (Funtion declaration in the `def esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-fn-no-init.js b/test/annexB/language/global-code/switch-dflt-global-exsting-fn-no-init.js index b797ef15fb94d3cefaf24944cb3ed277a92161cc..7d3421aaab44da52e7840dfe8180def0a7e97b1c 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-fn-no-init.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-fn-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(F). 2. If fnDefinable is true, then diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-fn-update.js b/test/annexB/language/global-code/switch-dflt-global-exsting-fn-update.js index cb65d245b237c0425b42844eb66f9314655e463f..4747826cc49cfab845dad191e0a6c44ea2caf80f 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-fn-update.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-fn-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-var-no-init.js b/test/annexB/language/global-code/switch-dflt-global-exsting-var-no-init.js index 68f10e3b677ca27a62752e5f02f25a888419487a..952a765b8d57d9756370805a662a5d3c9b729c53 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-var-no-init.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-var-no-init.js @@ -6,9 +6,9 @@ description: Existing variable binding is not modified (Funtion declaration in t esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). diff --git a/test/annexB/language/global-code/switch-dflt-global-exsting-var-update.js b/test/annexB/language/global-code/switch-dflt-global-exsting-var-update.js index 207509cd1c6b5e9dc1f6e2c6da26bbafc7d73711..83e131a0355453c4dabcfa7e127fe163bbf1bf29 100644 --- a/test/annexB/language/global-code/switch-dflt-global-exsting-var-update.js +++ b/test/annexB/language/global-code/switch-dflt-global-exsting-var-update.js @@ -6,13 +6,13 @@ description: Variable-scoped binding is updated following evaluation (Funtion de esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation [...] c. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in 14.1.21: - + i. Let genv be the running execution context's VariableEnvironment. ii. Let genvRec be genv's EnvironmentRecord. ii. Let benv be the running execution context's LexicalEnvironment. diff --git a/test/annexB/language/global-code/switch-dflt-global-init.js b/test/annexB/language/global-code/switch-dflt-global-init.js index 51cbb4974bb141c503669e9c0ac75e695ee7e37d..d9eb1c035fae913084f2eca290bb31c0fcf756b3 100644 --- a/test/annexB/language/global-code/switch-dflt-global-init.js +++ b/test/annexB/language/global-code/switch-dflt-global-init.js @@ -7,15 +7,15 @@ esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] includes: [fnGlobalObject.js, propertyHelper.js] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If declaredFunctionOrVarNames does not contain F, then i. Perform ? envRec.CreateGlobalFunctionBinding(F, undefined, false). ii. Append F to declaredFunctionOrVarNames. [...] - + ---*/ var global = fnGlobalObject(); assert.sameValue(f, undefined, 'binding is initialized to `undefined`'); diff --git a/test/annexB/language/global-code/switch-dflt-global-no-skip-try.js b/test/annexB/language/global-code/switch-dflt-global-no-skip-try.js new file mode 100644 index 0000000000000000000000000000000000000000..c838b58155485810a9e9b7b37bb3a4e083dcdaa9 --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-no-skip-try.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-no-skip-try.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.sameValue( + f, undefined, 'Initialized binding created prior to evaluation' +); + +try { + throw null; +} catch (f) { + +switch (1) { + default: + function f() { return 123; } +} + +} + +assert.sameValue( + typeof f, + 'function', + 'binding value is updated following evaluation' +); +assert.sameValue(f(), 123); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-block.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-block.js new file mode 100644 index 0000000000000000000000000000000000000000..fc3c87acbe309018e746c252289ee78dc24bef6d --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-block.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-block.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (Block statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +{ +let f = 123; + +switch (1) { + default: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-in.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-in.js new file mode 100644 index 0000000000000000000000000000000000000000..c6b6432d78c4e0a645b72030758bf6f17564ba00 --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-in.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-in.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f in { key: 0 }) { + +switch (1) { + default: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-of.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-of.js new file mode 100644 index 0000000000000000000000000000000000000000..bd4fc217ffec6b1c2032ff9611a8015fb2a67468 --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for-of.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for-of.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for-of statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f of [0]) { + +switch (1) { + default: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for.js new file mode 100644 index 0000000000000000000000000000000000000000..8832b56656c64b73c7867445cf7f0079e49c4c3b --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-for.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-for.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (for statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +for (let f; ; ) { + +switch (1) { + default: + function f() { } +} + + break; +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-switch.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-switch.js new file mode 100644 index 0000000000000000000000000000000000000000..4b79fbb219e5f72c1f54334661a6327b2fc55ca6 --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-switch.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-switch.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension not observed when creation of variable binding would produce an early error (switch statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +switch (0) { + default: + let f; + +switch (1) { + default: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err-try.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-try.js new file mode 100644 index 0000000000000000000000000000000000000000..03f953d24ecad12c7d517a7b95cfbfb297572282 --- /dev/null +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err-try.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/global-skip-early-err-try.case +// - src/annex-b-fns/global/switch-dflt.template +/*--- +description: Extension is observed when creation of variable binding would not produce an early error (try statement) (Funtion declaration in the `default` clause of a `switch` statement in the global scope) +esid: sec-web-compat-globaldeclarationinstantiation +es6id: B.3.3.2 +flags: [generated, noStrict] +info: | + B.3.3.2 Changes to GlobalDeclarationInstantiation + + [...] + b. If replacing the FunctionDeclaration f with a VariableStatement that has + F as a BindingIdentifier would not produce any Early Errors for script, + then + [...] + + B.3.5 VariableStatements in Catch Blocks + + [...] + - It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block unless CatchParameter is + CatchParameter:BindingIdentifier and that element is only bound by a + VariableStatement, the VariableDeclarationList of a for statement, or the + ForBinding of a for-in statement. +---*/ +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created prior to evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created prior to evaluation' +); + +try { + throw {}; +} catch ({ f }) { + +switch (1) { + default: + function f() { } +} + +} + +assert.throws(ReferenceError, function() { + f; +}, 'An initialized binding is not created following evaluation'); +assert.sameValue( + typeof f, + 'undefined', + 'An uninitialized binding is not created following evaluation' +); diff --git a/test/annexB/language/global-code/switch-dflt-global-skip-early-err.js b/test/annexB/language/global-code/switch-dflt-global-skip-early-err.js index 2279d75d38241741cacb0380385b2d44667360d0..3c56b02c48aeded97b59c66e6b9ece3e9f0b0af0 100644 --- a/test/annexB/language/global-code/switch-dflt-global-skip-early-err.js +++ b/test/annexB/language/global-code/switch-dflt-global-skip-early-err.js @@ -6,9 +6,9 @@ description: Extension not observed when creation of variable binding would prod esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] b. If replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors for script, diff --git a/test/annexB/language/global-code/switch-dflt-global-update.js b/test/annexB/language/global-code/switch-dflt-global-update.js index a663b4d2b8d7b3d2d832d42dc35ab1664a8765c9..399070d581c288a29402e345f3229edaa717f50f 100644 --- a/test/annexB/language/global-code/switch-dflt-global-update.js +++ b/test/annexB/language/global-code/switch-dflt-global-update.js @@ -6,9 +6,9 @@ description: Variable binding value is updated following evaluation (Funtion dec esid: sec-web-compat-globaldeclarationinstantiation es6id: B.3.3.2 flags: [generated, noStrict] -info: > +info: | B.3.3.2 Changes to GlobalDeclarationInstantiation - + [...] e. When the FunctionDeclaration f is evaluated, perform the following steps in place of the FunctionDeclaration Evaluation algorithm provided in