move var scope collector to before block - fixes #1153

This commit is contained in:
Sebastian McKenzie 2015-04-04 14:09:34 +11:00
parent 56335409d3
commit 7c710a0378

View File

@ -240,7 +240,6 @@ export default class Scope {
if (kind === "param") return;
if (kind === "hoisted" && local.kind === "let") return;
var duplicate = false;
duplicate ||= local.kind === "let" || local.kind === "const" || local.kind === "module";
duplicate ||= local.kind === "param" && (kind === "let" || kind === "const");
@ -477,6 +476,15 @@ export default class Scope {
this.traverse(path.get("body").node, blockVariableVisitor, this);
}
// Program, Function - var variables
if (path.isProgram() || path.isFunction()) {
this.traverse(path.node, functionVariableVisitor, {
blockId: path.get("id").node,
scope: this
});
}
// Program, BlockStatement, Function - let variables
if (path.isBlockStatement() || path.isProgram()) {
@ -495,15 +503,6 @@ export default class Scope {
this.registerBinding("let", path);
}
// Program, Function - var variables
if (path.isProgram() || path.isFunction()) {
this.traverse(path.node, functionVariableVisitor, {
blockId: path.get("id").node,
scope: this
});
}
// Program
if (path.isProgram()) {