should only throw an error for colliding param bindings for let and const

This commit is contained in:
Sebastian McKenzie 2015-04-03 23:11:04 +11:00
parent d64c2c0c45
commit e847f3685f
2 changed files with 10 additions and 6 deletions

View File

@ -106,12 +106,11 @@ var exportsVisitor = traverse.explode({
export default class DefaultFormatter {
constructor(file) {
this.defaultIds = object();
this.scope = file.scope;
this.file = file;
this.ids = object();
this.internalRemap = object();
this.defaultIds = object();
this.scope = file.scope;
this.file = file;
this.ids = object();
this.hasNonDefaultExports = false;

View File

@ -240,7 +240,12 @@ export default class Scope {
if (kind === "param") return;
if (kind === "hoisted" && local.kind === "let") return;
if (local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param") {
var duplicate = false;
duplicate ||= local.kind === "let" || local.kind === "const" || local.kind === "module";
duplicate ||= local.kind === "param" && (kind === "let" || kind === "const");
if (duplicate) {
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
}
}