diff --git a/src/env.cpp b/src/env.cpp index cc0682cb7..4fe41aba0 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -264,11 +264,9 @@ Value Env::exception_object() { ExceptionObject *Env::exception() { auto e = this; - for (;;) { + while (e) { if (e->m_exception) return e->m_exception; - if (!e->m_caller) - break; e = e->m_caller; } return nullptr; diff --git a/src/kernel_module.cpp b/src/kernel_module.cpp index a634b0a3d..f5d0386fd 100644 --- a/src/kernel_module.cpp +++ b/src/kernel_module.cpp @@ -473,9 +473,8 @@ Value KernelModule::puts(Env *env, Args args) { Value KernelModule::raise(Env *env, Value klass, Value message) { if (!klass) { - if (env->exception()) - klass = env->exception(); - else { + klass = env->exception(); + if (!klass) { klass = find_top_level_const(env, "RuntimeError"_s); message = new StringObject { "" }; }