Issue #2232 - Parse exported async functions.

This commit is contained in:
Job Bautista 2023-05-06 15:15:33 +08:00 committed by roytam1
commit 9693552c5c
2 changed files with 19 additions and 3 deletions

View file

@ -5778,14 +5778,15 @@ Parser<ParseHandler>::exportVariableStatement(uint32_t begin)
template <typename ParseHandler>
typename ParseHandler::UnaryNodeType
Parser<ParseHandler>::exportFunctionDeclaration(uint32_t begin)
Parser<ParseHandler>::exportFunctionDeclaration(uint32_t begin,
FunctionAsyncKind asyncKind /* = SyncFunction */)
{
if (!abortIfSyntaxParser())
return null();
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_FUNCTION));
Node kid = functionStmt(pos().begin, YieldIsKeyword, NameRequired);
Node kid = functionStmt(pos().begin, YieldIsKeyword, NameRequired, asyncKind);
if (!kid)
return null();
@ -6008,6 +6009,20 @@ Parser<ParseHandler>::exportDeclaration()
case TOK_FUNCTION:
return exportFunctionDeclaration(begin);
case TOK_ASYNC: {
TokenKind nextSameLine = TOK_EOF;
if (!tokenStream.peekTokenSameLine(&nextSameLine))
return null();
if (nextSameLine == TOK_FUNCTION) {
tokenStream.consumeKnownToken(TOK_FUNCTION);
return exportFunctionDeclaration(begin, AsyncFunction);
}
error(JSMSG_DECLARATION_AFTER_EXPORT);
return null();
}
case TOK_CLASS:
return exportClassDeclaration(begin);

View file

@ -1337,7 +1337,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
BinaryNodeType exportBatch(uint32_t begin);
bool checkLocalExportNames(ListNodeType node);
Node exportClause(uint32_t begin);
UnaryNodeType exportFunctionDeclaration(uint32_t begin);
UnaryNodeType exportFunctionDeclaration(uint32_t begin,
FunctionAsyncKind asyncKind = SyncFunction);
UnaryNodeType exportVariableStatement(uint32_t begin);
UnaryNodeType exportClassDeclaration(uint32_t begin);
UnaryNodeType exportLexicalDeclaration(uint32_t begin, DeclarationKind kind);