add bindingEquals, typeEquals, referenceEquals helper methods to Scope

This commit is contained in:
Sebastian McKenzie 2015-02-06 23:07:10 +11:00
parent 399d835285
commit a6d1a5a724
2 changed files with 6 additions and 2 deletions

View File

@ -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");
}

View File

@ -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",