diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-27 11:34:58 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-27 11:34:58 +0100 |
commit | 9494865f99e04e3a39c6925a4909162ecbfed10d (patch) | |
tree | 3ce75cd17633ae16a4b06ab729d55ce12e218ed3 | |
parent | d52c5a94b47db851f355d611dc750cf2c99b3193 (diff) | |
download | serenity-9494865f99e04e3a39c6925a4909162ecbfed10d.zip |
LibJS: Actually pop frames off of the scope stack when exiting a scope
-rw-r--r-- | Libraries/LibJS/Interpreter.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index 1dd5cc46db..5c3b486fab 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -86,8 +86,11 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, Vector<Argument> argu void Interpreter::exit_scope(const ScopeNode& scope_node) { - while (m_scope_stack.last().scope_node.ptr() != &scope_node) - m_scope_stack.take_last(); + while (!m_scope_stack.is_empty()) { + auto popped_scope = m_scope_stack.take_last(); + if (popped_scope.scope_node.ptr() == &scope_node) + break; + } // If we unwind all the way, just reset m_unwind_until so that future "return" doesn't break. if (m_scope_stack.is_empty()) |