fix duplicate declaration regression - fixes #1130

This commit is contained in:
Sebastian McKenzie 2015-04-03 06:47:41 +11:00
parent 5fbe147a5e
commit 8af3ea1c43
3 changed files with 7 additions and 6 deletions

View File

@ -5,9 +5,9 @@ import * as t from "../types";
export default function traverse(parent, opts, scope, state, parentPath) {
if (!parent) return;
if (!opts.noScope && !scope) {
if (!opts.noScope && (!scope || !parentPath)) {
if (parent.type !== "Program" && parent.type !== "File") {
throw new Error(`Must pass a scope unless traversing a Program/File got a ${parent.type} node`);
throw new Error(`Must pass a scope and parentPath unless traversing a Program/File got a ${parent.type} node`);
}
}

View File

@ -216,9 +216,9 @@ export default class TraversalPath {
this.opts = context.opts;
}
this.setScope(file);
this.type = this.node && this.node.type;
this.setScope(file);
}
_remove() {

View File

@ -57,7 +57,8 @@ var blockVariableVisitor = {
enter(node, parent, scope, state) {
if (this.isFunctionDeclaration() || this.isBlockScoped()) {
state.registerDeclaration(this);
} else if (this.isScope()) {
}
if (this.isScope()) {
this.skip();
}
}
@ -100,7 +101,7 @@ export default class Scope {
*/
traverse(node: Object, opts: Object, state?) {
traverse(node, opts, this, state);
traverse(node, opts, this, state, this.path);
}
/**