diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-16 10:24:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-16 10:25:00 +0200 |
commit | 13865c7c3d728404ee8fd917e34e6ab3fb140ecb (patch) | |
tree | 0ecec16cf0fb9980591094585e5bfc54e2d51222 /Libraries/LibJS/Interpreter.cpp | |
parent | 9b9086dcf0a798a1229a649e778f05746353bdca (diff) | |
download | serenity-13865c7c3d728404ee8fd917e34e6ab3fb140ecb.zip |
LibJS: Remove unreachable code in Interpreter::enter_scope()
Functions are handled and short-circuited at the head of enter_scope().
Diffstat (limited to 'Libraries/LibJS/Interpreter.cpp')
-rw-r--r-- | Libraries/LibJS/Interpreter.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index 4dbd06bdf4..06362bc173 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -125,17 +125,10 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, ArgumentVector argume bool pushed_lexical_environment = false; - if (scope_type != ScopeType::Function) { - // only a block, but maybe it has block-scoped variables! - if (!scope_variables_with_declaration_kind.is_empty()) { - auto* block_lexical_environment = heap().allocate<LexicalEnvironment>(move(scope_variables_with_declaration_kind), current_environment()); - m_call_stack.last().environment = block_lexical_environment; - pushed_lexical_environment = true; - } - } else if (scope_type == ScopeType::Function) { - for (auto& it : scope_variables_with_declaration_kind) { - current_environment()->set(it.key, it.value); - } + if (!scope_variables_with_declaration_kind.is_empty()) { + auto* block_lexical_environment = heap().allocate<LexicalEnvironment>(move(scope_variables_with_declaration_kind), current_environment()); + m_call_stack.last().environment = block_lexical_environment; + pushed_lexical_environment = true; } m_scope_stack.append({ scope_type, scope_node, pushed_lexical_environment }); |