Sfoglia il codice sorgente

LibJS: Convert values to boolean for JumpIfTrue/JumpIfFalse

Value::as_bool() might fail if the underlying value isn't already a
boolean value.
Gunnar Beutner 4 anni fa
parent
commit
216d27d4c1
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      Userland/Libraries/LibJS/Bytecode/Op.cpp

+ 2 - 2
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());
 }