Commit 763370fe authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Move 'async Identifier =>' handling to ParsePrimaryExpression

Change-Id: I7d95c0263649c69ff960925fcbde49e0ba9fa064
Reviewed-on: https://chromium-review.googlesource.com/c/1292059Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56843}
parent 4cc03b61
......@@ -1764,15 +1764,22 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
if (IsInRange(token, Token::IDENTIFIER,
Token::ESCAPED_STRICT_RESERVED_WORD)) {
if (token == Token::ASYNC && !scanner()->HasLineTerminatorAfterNext() &&
PeekAhead() == Token::FUNCTION) {
BindingPatternUnexpectedToken();
Consume(Token::ASYNC);
return ParseAsyncFunctionLiteral(ok);
}
// Using eval or arguments in this context is OK even in strict mode.
IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK);
return impl()->ExpressionFromIdentifier(name, beg_pos);
InferName infer = InferName::kYes;
if (V8_UNLIKELY(impl()->IsAsync(name) &&
!scanner()->HasLineTerminatorBeforeNext())) {
if (peek() == Token::FUNCTION) {
BindingPatternUnexpectedToken();
return ParseAsyncFunctionLiteral(ok);
}
// async Identifier => AsyncConciseBody
if (peek_any_identifier() && PeekAhead() == Token::ARROW) {
name = ParseAndClassifyIdentifier(CHECK_OK);
infer = InferName::kNo;
}
}
return impl()->ExpressionFromIdentifier(name, beg_pos, infer);
}
DCHECK_IMPLIES(Token::IsAnyIdentifier(token), token == Token::ENUM);
......@@ -2732,16 +2739,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
// that we have only a trivial expression to parse.
ExpressionT expression = ParseConditionalExpression(accept_IN, CHECK_OK);
if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() &&
PeekAhead() == Token::ARROW) {
// async Identifier => AsyncConciseBody
IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK);
expression =
impl()->ExpressionFromIdentifier(name, position(), InferName::kNo);
// Remove `async` keyword from inferred name stack.
fni_.RemoveAsyncKeywordFromEnd();
}
if (peek() == Token::ARROW) {
Scanner::Location arrow_loc = scanner()->peek_location();
if (!is_async && !parenthesized_formals) {
......
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