From 25a3bbce91f16ba45b823f26a1020d7a2d6abc3c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 13 Apr 2015 15:44:54 -0700 Subject: [PATCH] only make parenthesized object patterns illegal - fixes #1254, ref jshint/jshint#2269 --- src/expression.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/expression.js b/src/expression.js index 8eaeab610f..cf8370c51c 100755 --- a/src/expression.js +++ b/src/expression.js @@ -103,12 +103,8 @@ pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos, afterLeftParse) { node.left = this.type === tt.eq ? this.toAssignable(left) : left refShorthandDefaultPos.start = 0 // reset because shorthand default was used correctly this.checkLVal(left) - if (left.parenthesizedExpression) { - if (left.type === "ObjectPattern") { - 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"); - } + if (left.parenthesizedExpression && left.type === "ObjectPattern") { + this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`"); } this.next() node.right = this.parseMaybeAssign(noIn)