diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 38d656822b..3c13c0f3f0 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -703,10 +703,13 @@ ThrowCompletionOr perform_eval(GlobalObject& global_object, Value x, Call executable->name = "eval"sv; if (Bytecode::g_dump_bytecode) executable->dump(); - eval_result = TRY(bytecode_interpreter->run(*executable)); - // Turn potentially empty JS::Value from the bytecode interpreter into an empty Optional - if (eval_result.has_value() && eval_result->is_empty()) - eval_result = {}; + auto result_or_error = bytecode_interpreter->run_and_return_frame(*executable, nullptr); + if (result_or_error.value.is_error()) + return result_or_error.value.release_error(); + + auto& result = result_or_error.frame->registers[0]; + if (!result.is_empty()) + eval_result = result; } else { auto& ast_interpreter = vm.interpreter(); eval_result = TRY(program->execute(ast_interpreter, global_object));