Move fix into #checkBlockScopedCollisions
This commit is contained in:
parent
48c114169f
commit
4b297907d1
@ -346,6 +346,10 @@ export default class Scope {
|
||||
// ignore parameters
|
||||
if (kind === "param") return;
|
||||
|
||||
// Ignore existing binding if it's the name of the current function or
|
||||
// class expression
|
||||
if (local.kind === "local") return;
|
||||
|
||||
// ignore hoisted functions if there's also a local let
|
||||
if (kind === "hoisted" && local.kind === "let") return;
|
||||
|
||||
@ -520,10 +524,6 @@ export default class Scope {
|
||||
for (const id of (ids[name]: Array<Object>)) {
|
||||
let local = this.getOwnBinding(name);
|
||||
|
||||
// Ignore existing binding if it's the name of the current function or class
|
||||
// expression
|
||||
if (local && local.kind === "local") local = null;
|
||||
|
||||
if (local) {
|
||||
// same identifier so continue safely as we're likely trying to register it
|
||||
// multiple times
|
||||
|
||||
8
packages/babel-traverse/test/fixtures/regression/constant-shadows-function-name/actual.js
vendored
Normal file
8
packages/babel-traverse/test/fixtures/regression/constant-shadows-function-name/actual.js
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
let obj = {
|
||||
foo: function foo() {
|
||||
let foo = true;
|
||||
console.log('foo ran');
|
||||
}
|
||||
};
|
||||
|
||||
obj.foo();
|
||||
7
packages/babel-traverse/test/fixtures/regression/constant-shadows-function-name/expected.js
vendored
Normal file
7
packages/babel-traverse/test/fixtures/regression/constant-shadows-function-name/expected.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
let obj = {
|
||||
foo: function foo() {
|
||||
let foo = true;
|
||||
console.log('foo ran');
|
||||
}
|
||||
};
|
||||
obj.foo();
|
||||
Loading…
x
Reference in New Issue
Block a user