diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-07 22:53:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 10:42:45 +0200 |
commit | 216d27d4c13be78a859b8bcc7a1abc555a58f322 (patch) | |
tree | 19ddbb5161aafa72224da182a570d7b5d7c5a501 /Userland/Libraries | |
parent | aefb7995f138b83d838788ecd1906860bbb4af20 (diff) | |
download | serenity-216d27d4c13be78a859b8bcc7a1abc555a58f322.zip |
LibJS: Convert values to boolean for JumpIfTrue/JumpIfFalse
Value::as_bool() might fail if the underlying value isn't already a
boolean value.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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()); } |