invalid destructuring assignments like {0} = x now causes syntax error

This commit is contained in:
satyr
2010-10-25 04:45:31 +09:00
parent e007f69c71
commit c8d994a97d
3 changed files with 11 additions and 1 deletions

View File

@@ -899,7 +899,7 @@
return If.unfoldSoak(o, this, 'variable');
};
Assign.prototype.compileNode = function(o) {
var _ref2, isValue, match, name, val;
var _ref2, assignee, isValue, match, name, val;
if (isValue = this.variable instanceof Value) {
if (this.variable.isArray() || this.variable.isObject()) {
return this.compilePatternMatch(o);
@@ -917,6 +917,9 @@
if (this.context === 'object') {
return "" + name + ": " + val;
}
if (!(this.variable.isComplex() || IDENTIFIER.test(assignee = this.variable.unwrap().value))) {
throw SyntaxError("" + assignee + " cannot be assigned.");
}
if (!(isValue && (this.variable.hasProperties() || this.variable.namespaced))) {
o.scope.find(name);
}