Commit 7f474f93 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Move unexpected arrow-start tracking into the arrow case

This will avoid queueing the error for any valid-syntax JS, whereas currently
we'll queue it for any assignment expression that doesn't look like the start
of an arrow function.

The final error will look the same even if we delay queueing it. Since the
formals weren't parenthesized we won't actually throw the queued error, but the
tracked "binding pattern error".

Change-Id: I80e9d8ef4fb8244829c274a7d656637080583769
Reviewed-on: https://chromium-review.googlesource.com/c/1270583Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56469}
parent d46467c0
......@@ -2867,9 +2867,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
IsValidArrowFormalParametersStart(PeekAhead());
bool parenthesized_formals = peek() == Token::LPAREN;
if (!is_async && !parenthesized_formals) {
ArrowFormalParametersUnexpectedToken();
}
// Parse a simple, faster sub-grammar (primary expression) if it's evident
// that we have only a trivial expression to parse.
......@@ -2892,6 +2889,9 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
if (peek() == Token::ARROW) {
Scanner::Location arrow_loc = scanner()->peek_location();
if (!is_async && !parenthesized_formals) {
ArrowFormalParametersUnexpectedToken();
}
ValidateArrowFormalParameters(expression, parenthesized_formals, is_async,
CHECK_OK);
// This reads strangely, but is correct: it checks whether any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment