Fix scope check for 2nd+ lexical bindings (#9600)

This commit is contained in:
Daniel Tschinder 2019-02-27 15:53:28 -08:00 committed by GitHub
parent 9aec606c69
commit 5cb280f986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 2 deletions

View File

@ -117,8 +117,7 @@ export default class ScopeHandler {
const scope = this.scopeStack[i];
if (
(scope.lexical.indexOf(name) > -1 &&
!(scope.flags & SCOPE_SIMPLE_CATCH) &&
scope.lexical[0] === name) ||
!(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||
(!this.treatFunctionsAsVarInScope(scope) &&
scope.functions.indexOf(name) > -1)
) {

View File

@ -0,0 +1,5 @@
{
let bar;
var foo = 1;
let foo = 1;
}

View File

@ -0,0 +1,3 @@
{
"throws": "Identifier 'foo' has already been declared (4:6)"
}

View File

@ -0,0 +1,3 @@
let bar;
var foo = 1;
let foo = 1;

View File

@ -0,0 +1,3 @@
{
"throws": "Identifier 'foo' has already been declared (3:4)"
}

View File

@ -0,0 +1,5 @@
{
let bar;
let foo = 1;
var foo = 1;
}

View File

@ -0,0 +1,3 @@
{
"throws": "Identifier 'foo' has already been declared (4:6)"
}

View File

@ -0,0 +1,3 @@
let bar;
let foo = 1;
var foo = 1;

View File

@ -0,0 +1,3 @@
{
"throws": "Identifier 'foo' has already been declared (3:4)"
}