1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibJS: Allow 'yield' and 'await' as function expression names

The spec says so, and test262 checks for this too.
This commit is contained in:
Ali Mohammad Pur 2021-07-02 15:11:11 +04:30 committed by Andreas Kling
parent a6fe27423a
commit 2e00731ddb
2 changed files with 8 additions and 0 deletions

View file

@ -1417,6 +1417,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u8 parse_options)
ScopePusher scope(*this, ScopePusher::Var | ScopePusher::Function);
constexpr auto is_function_expression = IsSame<FunctionNodeType, FunctionExpression>;
auto is_generator = (parse_options & FunctionNodeParseOptions::IsGeneratorFunction) != 0;
String name;
if (parse_options & FunctionNodeParseOptions::CheckForFunctionAndName) {
@ -1431,6 +1432,8 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u8 parse_options)
if (FunctionNodeType::must_have_name() || match(TokenType::Identifier))
name = consume(TokenType::Identifier).value();
else if (is_function_expression && (match(TokenType::Yield) || match(TokenType::Await)))
name = consume().value();
}
consume(TokenType::ParenOpen);
i32 function_length = -1;