Browse Source

Merge pull request #292 from rollup/call-use-once

Check isUsed to prevent potentially infinite recursion
better-aggressive
Rich Harris 10 years ago
parent
commit
1ef16e2843
  1. 4
      src/Module.js
  2. 4
      src/ast/Scope.js

4
src/Module.js

@ -17,6 +17,8 @@ class SyntheticDefaultDeclaration {
this.original = null; this.original = null;
this.isExported = false; this.isExported = false;
this.aliases = []; this.aliases = [];
this.isUsed = false;
} }
addAlias ( declaration ) { addAlias ( declaration ) {
@ -42,6 +44,8 @@ class SyntheticDefaultDeclaration {
} }
use () { use () {
if ( this.isUsed ) return;
this.isUsed = true; this.isUsed = true;
this.statement.mark(); this.statement.mark();

4
src/ast/Scope.js

@ -40,6 +40,8 @@ class Declaration {
this.isReassigned = false; this.isReassigned = false;
this.aliases = []; this.aliases = [];
this.isUsed = false;
} }
addAlias ( declaration ) { addAlias ( declaration ) {
@ -61,6 +63,8 @@ class Declaration {
} }
use () { use () {
if ( this.isUsed ) return;
this.isUsed = true; this.isUsed = true;
if ( this.statement ) this.statement.mark(); if ( this.statement ) this.statement.mark();

Loading…
Cancel
Save