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

LibJS: Disallow async generator functions called 'await' or 'yield'

This commit is contained in:
davidot 2021-12-19 20:19:15 +01:00 committed by Linus Groh
parent c8e80690a7
commit 81312986fe
4 changed files with 12 additions and 0 deletions

View file

@ -2476,6 +2476,9 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u8 parse_options)
check_identifier_name_for_assignment_validity(name);
if (function_kind == FunctionKind::AsyncGenerator && (name == "await"sv || name == "yield"sv))
syntax_error(String::formatted("async generator function is not allowed to be called '{}'", name));
if (m_state.in_class_static_init_block && name == "await"sv)
syntax_error("'await' is a reserved word");
}