diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 556ac6daa7be..97bd8ab171fc 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -40,12 +40,6 @@ import { SCOPE_PROGRAM, } from "../util/scopeflags"; -const unwrapParenthesizedExpression = node => { - return node.type === "ParenthesizedExpression" - ? unwrapParenthesizedExpression(node.expression) - : node; -}; - export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js +parseBlock: ( @@ -207,27 +201,6 @@ export default class ExpressionParser extends LValParser { refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly this.checkLVal(left, undefined, undefined, "assignment expression"); - - const maybePattern = unwrapParenthesizedExpression(left); - - let patternErrorMsg; - if (maybePattern.type === "ObjectPattern") { - patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; - } else if (maybePattern.type === "ArrayPattern") { - patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; - } - - if ( - patternErrorMsg && - ((left.extra && left.extra.parenthesized) || - left.type === "ParenthesizedExpression") - ) { - this.raise( - maybePattern.start, - `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`, - ); - } - this.next(); node.right = this.parseMaybeAssign(noIn); return this.finishNode(node, "AssignmentExpression"); diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json index eff49cbfba64..4c7ba6fba51c 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" + "throws": "Invalid parenthesized assignment pattern (1:1)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json index f37c4bc95c57..2acd7adfa4ee 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" -} + "throws": "Invalid parenthesized assignment pattern (1:1)" +} \ No newline at end of file