summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Parser.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-02 14:55:34 +0430
committerAndreas Kling <kling@serenityos.org>2021-07-02 14:59:03 +0200
commitbd9f28bba694b7b015454fc486e43cd78b5418cf (patch)
tree545fc9e425ea3818eafcdbd823573a82c999ec8a /Userland/Libraries/LibJS/Parser.cpp
parent0292ad33eb209e5bb23f4d4a552489dbc8ada203 (diff)
downloadserenity-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.cpp4
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>()) {