[parser] Immediately throw if () isn't followed by =>

Change-Id: Iefea33f47ee4492c9c4d4e105e30f7e2d9128bc7
Reviewed-on: https://chromium-review.googlesource.com/c/1319576
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57268}
This commit is contained in:
Toon Verwaest 2018-11-06 10:42:45 +01:00 committed by Commit Bot
parent 32224e4a14
commit ab101d05ab

View File

@ -1772,11 +1772,9 @@ ParserBase<Impl>::ParsePrimaryExpression() {
if (pattern_error) ArrowFormalParametersUnexpectedToken();
Consume(Token::LPAREN);
if (Check(Token::RPAREN)) {
// ()=>x. The continuation that looks for the => is in
// ()=>x. The continuation that consumes the => is in
// ParseAssignmentExpression.
classifier()->RecordExpressionError(scanner()->location(),
MessageTemplate::kUnexpectedToken,
Token::String(Token::RPAREN));
if (peek() != Token::ARROW) ReportUnexpectedToken(Token::RPAREN);
return factory()->NewEmptyParentheses(beg_pos);
}
// Heuristically try to detect immediately called functions before