From c2da77d7ec146795ada6d73d20bcbef4cd48db3a 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 --- CHANGELOG.md | 5 +++++ src/acorn/src/expression.js | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e221b6d11..10de11c231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty/broken releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.1.8 + + * **Bug Fix** + * Only make parenthesized object pattern LHS illegal. + ## 5.1.7 * **Internal** diff --git a/src/acorn/src/expression.js b/src/acorn/src/expression.js index 8eaeab610f..cf8370c51c 100755 --- a/src/acorn/src/expression.js +++ b/src/acorn/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)