diff --git a/src/babel/traversal/scope/binding.js b/src/babel/traversal/scope/binding.js index fdb3471090..0f08028910 100644 --- a/src/babel/traversal/scope/binding.js +++ b/src/babel/traversal/scope/binding.js @@ -1,5 +1,5 @@ export default class Binding { - constructor({ identifier, scope, path, kind }) { + constructor({ existing, identifier, scope, path, kind }) { this.constantViolations = []; this.constant = true; @@ -12,6 +12,13 @@ export default class Binding { this.kind = kind; this.clearValue(); + + if (existing) { + this.constantViolations = this.constantViolations.concat( + existing.path, + existing.constantViolations + ); + } } /** diff --git a/src/babel/traversal/scope/index.js b/src/babel/traversal/scope/index.js index 7d828b5d04..20ba1065b8 100644 --- a/src/babel/traversal/scope/index.js +++ b/src/babel/traversal/scope/index.js @@ -508,6 +508,7 @@ export default class Scope { this.bindings[name] = new Binding({ identifier: id, + existing: local, scope: this, path: path, kind: kind