Commit 1486ea9c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Hoist invalid pattern/arrow reporting out of BinaryOp loop

We only need to report once that we're in an invalid path for binding patterns
and arrow formals.

Change-Id: I8c7edc1c2a9f431c98e09725d0534e661db76634
Reviewed-on: https://chromium-review.googlesource.com/c/1276626
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56579}
parent 544e1df1
...@@ -3036,13 +3036,13 @@ template <typename Impl> ...@@ -3036,13 +3036,13 @@ template <typename Impl>
typename ParserBase<Impl>::ExpressionT typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::ParseBinaryContinuation(ExpressionT x, int prec, int prec1, ParserBase<Impl>::ParseBinaryContinuation(ExpressionT x, int prec, int prec1,
bool accept_IN, bool* ok) { bool accept_IN, bool* ok) {
if (!accept_IN && peek() == Token::IN) return x;
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
do { do {
// prec1 >= 4 // prec1 >= 4
while (Token::Precedence(peek()) == prec1) { while (Token::Precedence(peek()) == prec1) {
if (!accept_IN && peek() == Token::IN) return x;
ValidateExpression(CHECK_OK); ValidateExpression(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
SourceRange right_range; SourceRange right_range;
int pos = peek_position(); int pos = peek_position();
...@@ -3083,6 +3083,7 @@ ParserBase<Impl>::ParseBinaryContinuation(ExpressionT x, int prec, int prec1, ...@@ -3083,6 +3083,7 @@ ParserBase<Impl>::ParseBinaryContinuation(ExpressionT x, int prec, int prec1,
impl()->RecordBinaryOperationSourceRange(x, right_range); impl()->RecordBinaryOperationSourceRange(x, right_range);
} }
} }
if (!accept_IN && peek() == Token::IN) return x;
} }
--prec1; --prec1;
} while (prec1 >= prec); } while (prec1 >= prec);
......
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