From 48c114169fff2ef795365ab6f2f0d0a70b11091e Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Sun, 19 Mar 2017 11:05:55 +0000 Subject: [PATCH] Move up check for binding kind "local" This puts the check before the call to `checkBlockScopedCollisions`. Fixes #4946. --- packages/babel-traverse/src/scope/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index 773cda8058..f9c1ab22e2 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -519,6 +519,11 @@ export default class Scope { for (const name in ids) { for (const id of (ids[name]: Array)) { 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 @@ -532,8 +537,6 @@ export default class Scope { // in `warnOnFlowBinding`. if (local && local.path.isFlow()) local = null; - if (local && local.kind === "local") local = null; - parent.references[name] = true; this.bindings[name] = new Binding({