Skip to content

Commit

Permalink
remove old parens validation
Browse files Browse the repository at this point in the history
  • Loading branch information
boweihan committed Oct 19, 2019
1 parent 7e158a1 commit 6807302
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
27 changes: 0 additions & 27 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -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: (
Expand Down Expand Up @@ -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");
Expand Down
@@ -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)"
}
@@ -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)"
}

0 comments on commit 6807302

Please sign in to comment.