From 6fa600fce31a0eb0d4708bf0d440c8e593e41dce Mon Sep 17 00:00:00 2001 From: davidot Date: Sat, 22 Jan 2022 13:03:06 +0100 Subject: [PATCH] LibJS: Fix the execution context for the bytecode interpreter Because we now push an execution context when creating the "normal" interpreter without valid environments we have to check for that case as well when running the bytecode interpreter. --- Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 9ac95b6339..3dfb8c509c 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -46,7 +46,8 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e TemporaryChange restore_executable { m_current_executable, &executable }; ExecutionContext execution_context(vm().heap()); - if (vm().execution_context_stack().is_empty()) { + if (vm().execution_context_stack().is_empty() || !vm().running_execution_context().lexical_environment) { + // The "normal" interpreter pushes an execution context without environment so in that case we also want to push one. execution_context.this_value = &global_object(); static FlyString global_execution_context_name = "(*BC* global execution context)"; execution_context.function_name = global_execution_context_name;