1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00

LibJS: Allow 'yield' as a variable name outside of generator functions

This commit is contained in:
Ali Mohammad Pur 2021-07-02 14:55:34 +04:30 committed by Andreas Kling
parent 0292ad33eb
commit bd9f28bba6

View file

@ -1680,6 +1680,10 @@ NonnullRefPtr<VariableDeclaration> Parser::parse_variable_declaration(bool for_l
consume(TokenType::Identifier).value());
} else if (auto pattern = parse_binding_pattern()) {
target = pattern.release_nonnull();
} else if (!m_state.in_generator_function_context && match(TokenType::Yield)) {
target = create_ast_node<Identifier>(
{ m_state.current_token.filename(), rule_start.position(), position() },
consume().value());
}
if (target.has<Empty>()) {