diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index 71b703b0ca..f24fc36c54 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -2827,16 +2827,30 @@ ParserBase::ParseLeftHandSideExpression( } } Scanner::Location spread_pos; - typename Traits::Type::ExpressionList args = - ParseArguments(&spread_pos, is_async, classifier, CHECK_OK); - - if (V8_UNLIKELY(is_async && peek() == Token::ARROW)) { - if (args->length()) { - // async ( Arguments ) => ... - return Traits::ExpressionListToExpression(args); + typename Traits::Type::ExpressionList args; + if (V8_UNLIKELY(is_async)) { + ExpressionClassifier async_classifier(this); + args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK); + if (peek() == Token::ARROW) { + ValidateBindingPattern(&async_classifier, CHECK_OK); + if (!async_classifier.is_valid_async_arrow_formal_parameters()) { + ReportClassifierError( + async_classifier.async_arrow_formal_parameters_error()); + *ok = false; + return this->EmptyExpression(); + } + if (args->length()) { + // async ( Arguments ) => ... + return Traits::ExpressionListToExpression(args); + } + // async () => ... + return factory()->NewEmptyParentheses(pos); + } else { + classifier->Accumulate(&async_classifier, + ExpressionClassifier::AllProductions); } - // async () => ... - return factory()->NewEmptyParentheses(pos); + } else { + args = ParseArguments(&spread_pos, false, classifier, CHECK_OK); } ArrowFormalParametersUnexpectedToken(classifier); diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index cb08f20e2c..02fc6d47a4 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -7726,6 +7726,14 @@ TEST(AsyncAwaitErrors) { "var f = async(await) => 1;", "var f = async(await = 1) => 1;", "var f = async(...[await]) => 1;", + + // v8:5190 + "var f = async(1) => 1", + "var f = async('str') => 1", + "var f = async(/foo/) => 1", + "var f = async({ foo = async(1) => 1 }) => 1", + "var f = async({ foo = async(a) => 1 })", + NULL }; // clang-format on