diff --git a/lib/6to5/transformation/transformers/es6/constants.js b/lib/6to5/transformation/transformers/es6/constants.js index ce888a17bd..0d11b5fb1b 100644 --- a/lib/6to5/transformation/transformers/es6/constants.js +++ b/lib/6to5/transformation/transformers/es6/constants.js @@ -24,8 +24,8 @@ var visitor = { // constant so we can just ignore it if (id === constant) continue; - var localBinding = scope.getBinding(key); - if (localBinding !== constant) continue; + // check if there's been a local binding that shadows this constant + if (scope.bindingEquals(key, constant)) continue; throw state.file.errorWithNode(id, key + " is read-only"); } diff --git a/lib/6to5/traversal/scope.js b/lib/6to5/traversal/scope.js index 17f13b04db..489c758b73 100644 --- a/lib/6to5/traversal/scope.js +++ b/lib/6to5/traversal/scope.js @@ -492,6 +492,10 @@ each({ binding: "Binding", type: "Type" }, function (title, type) { + Scope.prototype[type + "Equals"] = function (id, node) { + return this["get" + title](id) === node; + }; + each([ "get", "has",