From 109d99bb5e44d848726253c7cad756c15d91bb27 Mon Sep 17 00:00:00 2001 From: Amjad Masad Date: Fri, 13 May 2016 14:20:32 -0700 Subject: [PATCH] don't double count binding references (#3465) When, for example, a function is moved between from one place to another we recrawl and end up double counting any references it holds to the upper scope. This protects against that. (The same thing is done for constant violations in the `reassign` method) --- packages/babel-traverse/src/scope/binding.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/babel-traverse/src/scope/binding.js b/packages/babel-traverse/src/scope/binding.js index 04e9a14eda..32cfe54b99 100644 --- a/packages/babel-traverse/src/scope/binding.js +++ b/packages/babel-traverse/src/scope/binding.js @@ -82,6 +82,9 @@ export default class Binding { */ reference(path: NodePath) { + if (this.referencePaths.indexOf(path) !== -1) { + return; + } this.referenced = true; this.references++; this.referencePaths.push(path);