diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-07-02 14:55:34 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-02 14:59:03 +0200 |
commit | bd9f28bba694b7b015454fc486e43cd78b5418cf (patch) | |
tree | 545fc9e425ea3818eafcdbd823573a82c999ec8a /Userland/Libraries/LibJS/Parser.cpp | |
parent | 0292ad33eb209e5bb23f4d4a552489dbc8ada203 (diff) | |
download | serenity-bd9f28bba694b7b015454fc486e43cd78b5418cf.zip |
LibJS: Allow 'yield' as a variable name outside of generator functions
Diffstat (limited to 'Userland/Libraries/LibJS/Parser.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Parser.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 2c03379728..b423529c68 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -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>()) { |