From 11a8ef6d7a60e84ef2e4d16198c63fce4c91cd25 Mon Sep 17 00:00:00 2001 From: m3m0r7 Date: Mon, 25 Dec 2023 19:31:00 +0900 Subject: [PATCH] Fix looking for a version --- src/VM/Core/Runtime/RubyVM.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/VM/Core/Runtime/RubyVM.php b/src/VM/Core/Runtime/RubyVM.php index a93e548..c646fb1 100644 --- a/src/VM/Core/Runtime/RubyVM.php +++ b/src/VM/Core/Runtime/RubyVM.php @@ -101,12 +101,7 @@ public function runtime(RubyVersion $useVersion = null): Runtime { $selectedVersion = null; - // @var Runtime|null $kernel - if (!$useVersion instanceof \RubyVM\VM\Core\YARV\RubyVersion) { - $runtime = $this->registeredRuntimes[$selectedVersion = array_key_first($this->registeredRuntimes)] ?? null; - } else { - $runtime = $this->registeredRuntimes[$selectedVersion = $useVersion->value] ?? null; - } + $runtime = $this->registeredRuntimes[$selectedVersion = $useVersion?->value ?? $this->specifiedDefaultVersion->value] ?? null; if (!$runtime instanceof \RubyVM\VM\Core\Runtime\Runtime) { throw new RubyVMException('The RubyVM is not registered a kernel - You should call RubyVM::register method before calling the disassemble method');