From e847f3685fafdcdd2ca07dd67569c71a5c0d7760 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 3 Apr 2015 23:11:04 +1100 Subject: [PATCH] should only throw an error for colliding param bindings for let and const --- src/babel/transformation/modules/_default.js | 9 ++++----- src/babel/traversal/scope.js | 7 ++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/babel/transformation/modules/_default.js b/src/babel/transformation/modules/_default.js index 2d36ccb78f..ef30545cc7 100644 --- a/src/babel/transformation/modules/_default.js +++ b/src/babel/transformation/modules/_default.js @@ -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; diff --git a/src/babel/traversal/scope.js b/src/babel/traversal/scope.js index 99056e5bab..99052d2c8c 100644 --- a/src/babel/traversal/scope.js +++ b/src/babel/traversal/scope.js @@ -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); } }