only make parenthesized object patterns illegal - fixes #1254, ref jshint/jshint#2269

This commit is contained in:
Sebastian McKenzie 2015-04-13 15:44:54 -07:00
parent eed185c4dc
commit 25a3bbce91

View File

@ -103,12 +103,8 @@ pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos, afterLeftParse) {
node.left = this.type === tt.eq ? this.toAssignable(left) : left node.left = this.type === tt.eq ? this.toAssignable(left) : left
refShorthandDefaultPos.start = 0 // reset because shorthand default was used correctly refShorthandDefaultPos.start = 0 // reset because shorthand default was used correctly
this.checkLVal(left) this.checkLVal(left)
if (left.parenthesizedExpression) { if (left.parenthesizedExpression && left.type === "ObjectPattern") {
if (left.type === "ObjectPattern") { this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
} else {
this.raise(left.start, "Parenthesized left hand expressions are illegal");
}
} }
this.next() this.next()
node.right = this.parseMaybeAssign(noIn) node.right = this.parseMaybeAssign(noIn)