check for scope collisions in constants transformer - fixes #331
This commit is contained in:
parent
b2ad79cf88
commit
e6e93840a6
@ -6,7 +6,7 @@ var t = require("../../../types");
|
||||
var visitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isDeclaration(node) || t.isAssignmentExpression(node)) {
|
||||
var ids = t.getDeclarations(node);
|
||||
var ids = t.getBindingIdentifiers(node);
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
@ -21,6 +21,9 @@ var visitor = {
|
||||
// constant so we can just ignore it
|
||||
if (id === constant) continue;
|
||||
|
||||
var localBinding = scope.get(key, true);
|
||||
if (localBinding !== constant) continue;
|
||||
|
||||
throw state.file.errorWithNode(id, key + " is read-only");
|
||||
}
|
||||
} else if (t.isScope(node)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user