From 216d27d4c13be78a859b8bcc7a1abc555a58f322 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 7 Jun 2021 22:53:33 +0200 Subject: LibJS: Convert values to boolean for JumpIfTrue/JumpIfFalse Value::as_bool() might fail if the underlying value isn't already a boolean value. --- Userland/Libraries/LibJS/Bytecode/Op.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 68e4575f02..e3d7a997e1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -153,7 +153,7 @@ void JumpIfFalse::execute(Bytecode::Interpreter& interpreter) const { VERIFY(m_target.has_value()); auto result = interpreter.reg(m_result); - if (!result.as_bool()) + if (!result.to_boolean()) interpreter.jump(m_target.value()); } @@ -161,7 +161,7 @@ void JumpIfTrue::execute(Bytecode::Interpreter& interpreter) const { VERIFY(m_target.has_value()); auto result = interpreter.reg(m_result); - if (result.as_bool()) + if (result.to_boolean()) interpreter.jump(m_target.value()); } -- cgit v1.2.3