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)
This commit is contained in:
Amjad Masad 2016-05-13 14:20:32 -07:00 committed by Henry Zhu
parent 330071e59d
commit 109d99bb5e

View File

@ -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);