-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1023 from anba/redeclaration
Lexical redeclarations in block- and switch-statements Background feedback from @anba: In https://tc39.github.io/ecma262/#sec-switch-statement-static-semantics-lexicallydeclarednames, all lexically declared names from the different case clauses are combined. For each case clause, the LexicallyDeclaredNames definition from https://tc39.github.io/ecma262/#sec-block-static-semantics-lexicallydeclarednames applies, which has: ``` StatementListItem : Declaration 1. Return the BoundNames of Declaration. ``` And in https://tc39.github.io/ecma262/#prod-Declaration we've got: ``` Declaration[Yield, Await] : HoistableDeclaration[?Yield, ?Await, ~Default] ``` And in https://tc39.github.io/ecma262/#prod-HoistableDeclaration: ``` HoistableDeclaration[Yield, Await, Default] : FunctionDeclaration[?Yield, ?Await, ?Default] ``` And the BoundNames of a FunctionDeclaration is its BindingIdentifier https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-boundnames. And there's also B3.3.5 (https://tc39.github.io/ecma262/#sec-switch-duplicates-allowed-static-semantics) which allows duplicate FunctionDeclarations in sloppy mode in switch-statements.
- Loading branch information
Showing
240 changed files
with
3,574 additions
and
159 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...lare-allow-sloppy-function/block-attempt-to-redeclare-async-function-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to- | ||
name: AsyncFunctionDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-functions] | ||
---*/ | ||
|
||
{ async function f() {} /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...are-allow-sloppy-function/block-attempt-to-redeclare-async-generator-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to- | ||
name: AsyncGeneratorDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-iteration] | ||
---*/ | ||
|
||
{ async function* f() {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ons/redeclare-allow-sloppy-function/block-attempt-to-redeclare-class-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/class-declaration-attempt-to- | ||
name: ClassDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ class f {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ons/redeclare-allow-sloppy-function/block-attempt-to-redeclare-const-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/const-declaration-attempt-to- | ||
name: LexicalDeclaration (const) in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ const f = 0; /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
.../redeclare-allow-sloppy-function/block-attempt-to-redeclare-function-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/function-declaration-attempt-to- | ||
name: FunctionDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [onlyStrict] | ||
---*/ | ||
|
||
{ function f() {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...redeclare-allow-sloppy-function/block-attempt-to-redeclare-generator-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/generator-declaration-attempt-to- | ||
name: GeneratorDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ function* f() {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...tions/redeclare-allow-sloppy-function/block-attempt-to-redeclare-let-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/let-declaration-attempt-to- | ||
name: LexicalDeclaration (let) in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains | ||
any duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ let f; /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...tions/redeclare-allow-sloppy-function/block-attempt-to-redeclare-var-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/var-declaration-attempt-to- | ||
name: VariableDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
StatementList also occurs in the VarDeclaredNames of StatementList. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ var f; /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...are-allow-sloppy-function/switch-attempt-to-redeclare-async-function-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to- | ||
name: AsyncFunctionDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-functions] | ||
---*/ | ||
|
||
switch (0) { case 1: async function f() {} default: /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...re-allow-sloppy-function/switch-attempt-to-redeclare-async-generator-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to- | ||
name: AsyncGeneratorDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-iteration] | ||
---*/ | ||
|
||
switch (0) { case 1: async function* f() {} default: /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ns/redeclare-allow-sloppy-function/switch-attempt-to-redeclare-class-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/class-declaration-attempt-to- | ||
name: ClassDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
switch (0) { case 1: class f {} default: /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ns/redeclare-allow-sloppy-function/switch-attempt-to-redeclare-const-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/const-declaration-attempt-to- | ||
name: LexicalDeclaration (const) in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
switch (0) { case 1: const f = 0; default: /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...redeclare-allow-sloppy-function/switch-attempt-to-redeclare-function-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/function-declaration-attempt-to- | ||
name: FunctionDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [onlyStrict] | ||
---*/ | ||
|
||
switch (0) { case 1: function f() {} default: /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...edeclare-allow-sloppy-function/switch-attempt-to-redeclare-generator-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to- | ||
name: GeneratorDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
switch (0) { case 1: function* f() {} default: /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ions/redeclare-allow-sloppy-function/switch-attempt-to-redeclare-let-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/let-declaration-attempt-to- | ||
name: LexicalDeclaration (let) in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any | ||
duplicate entries. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
switch (0) { case 1: let f; default: /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
...ions/redeclare-allow-sloppy-function/switch-attempt-to-redeclare-var-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/statements/switch/syntax/redeclaration/var-declaration-attempt-to- | ||
name: VariableDeclaration in SwitchStatement | ||
esid: sec-switch-statement-static-semantics-early-errors | ||
info: | | ||
SwitchStatement : switch ( Expression ) CaseBlock | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
CaseBlock also occurs in the VarDeclaredNames of CaseBlock. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
switch (0) { case 1: var f; default: /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...ations/redeclare-allow-var/block-attempt-to-redeclare-async-function-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to- | ||
name: AsyncFunctionDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
StatementList also occurs in the VarDeclaredNames of StatementList. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-functions] | ||
---*/ | ||
|
||
{ async function f() {} /*{ body }*/ } |
19 changes: 19 additions & 0 deletions
19
...tions/redeclare-allow-var/block-attempt-to-redeclare-async-generator-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to- | ||
name: AsyncGeneratorDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
StatementList also occurs in the VarDeclaredNames of StatementList. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
flags: [async-iteration] | ||
---*/ | ||
|
||
{ async function* f() {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
src/declarations/redeclare-allow-var/block-attempt-to-redeclare-class-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/class-declaration-attempt-to- | ||
name: ClassDeclaration in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
StatementList also occurs in the VarDeclaredNames of StatementList. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ class f {} /*{ body }*/ } |
18 changes: 18 additions & 0 deletions
18
src/declarations/redeclare-allow-var/block-attempt-to-redeclare-const-declaration.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2017 André Bargull. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
path: language/block-scope/syntax/redeclaration/const-declaration-attempt-to- | ||
name: LexicalDeclaration (const) in BlockStatement | ||
esid: sec-block-static-semantics-early-errors | ||
info: | | ||
Block : { StatementList } | ||
|
||
It is a Syntax Error if any element of the LexicallyDeclaredNames of | ||
StatementList also occurs in the VarDeclaredNames of StatementList. | ||
negative: | ||
phase: early | ||
type: SyntaxError | ||
---*/ | ||
|
||
{ const f = 0; /*{ body }*/ } |
Oops, something went wrong.