Browse Source

prevent illegal reassignments, part 2

declarations-and-references
Rich-Harris 9 years ago
parent
commit
a66cad653c
  1. 13
      src/Statement.js

13
src/Statement.js

@ -105,11 +105,9 @@ export default class Statement {
return this.skip();
}
if ( isReference( node, parent ) ) {
const reference = new Reference( node, scope );
references.push( reference );
let isReassignment;
if ( parent.type in modifierNodes ) {
if ( parent && parent.type in modifierNodes ) {
let subject = parent[ modifierNodes[ parent.type ] ];
let depth = 0;
@ -133,10 +131,15 @@ export default class Statement {
}
}
reference.isReassignment = !depth;
isReassignment = !depth;
}
if ( isReference( node, parent ) ) {
const reference = new Reference( node, scope );
references.push( reference );
reference.isImmediatelyUsed = !readDepth;
reference.isReassignment = isReassignment;
this.skip(); // don't descend from `foo.bar.baz` into `foo.bar`
}

Loading…
Cancel
Save