Fix scope check for 2nd+ lexical bindings (#9600)
This commit is contained in:
parent
9aec606c69
commit
5cb280f986
@ -117,8 +117,7 @@ export default class ScopeHandler {
|
|||||||
const scope = this.scopeStack[i];
|
const scope = this.scopeStack[i];
|
||||||
if (
|
if (
|
||||||
(scope.lexical.indexOf(name) > -1 &&
|
(scope.lexical.indexOf(name) > -1 &&
|
||||||
!(scope.flags & SCOPE_SIMPLE_CATCH) &&
|
!(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||
|
||||||
scope.lexical[0] === name) ||
|
|
||||||
(!this.treatFunctionsAsVarInScope(scope) &&
|
(!this.treatFunctionsAsVarInScope(scope) &&
|
||||||
scope.functions.indexOf(name) > -1)
|
scope.functions.indexOf(name) > -1)
|
||||||
) {
|
) {
|
||||||
|
|||||||
5
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js
vendored
Normal file
5
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
let bar;
|
||||||
|
var foo = 1;
|
||||||
|
let foo = 1;
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Identifier 'foo' has already been declared (4:6)"
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let bar;
|
||||||
|
var foo = 1;
|
||||||
|
let foo = 1;
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Identifier 'foo' has already been declared (3:4)"
|
||||||
|
}
|
||||||
5
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js
vendored
Normal file
5
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
let bar;
|
||||||
|
let foo = 1;
|
||||||
|
var foo = 1;
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Identifier 'foo' has already been declared (4:6)"
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
let bar;
|
||||||
|
let foo = 1;
|
||||||
|
var foo = 1;
|
||||||
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Identifier 'foo' has already been declared (3:4)"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user