From fe6bd9650f8e19e1618846b511b9cc281cbb26fa Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 10 Mar 2020 11:08:37 +0100 Subject: [PATCH] LibJS: Use Value::to_boolean() wherever we haven't checked is_boolean() Unless we've verified that a Value is a boolean, we should not be calling as_bool() on it. --- Libraries/LibJS/AST.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index e1260c1804..f4ea63b4ef 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -191,7 +191,7 @@ Value BinaryExpression::execute(Interpreter& interpreter) const case BinaryOp::TypedEquals: return typed_eq(lhs_result, rhs_result); case BinaryOp::TypedInequals: - return Value(!typed_eq(lhs_result, rhs_result).as_bool()); + return Value(!typed_eq(lhs_result, rhs_result).to_boolean()); case BinaryOp::Greater: return greater(lhs_result, rhs_result); case BinaryOp::Smaller: @@ -232,7 +232,7 @@ Value UnaryExpression::execute(Interpreter& interpreter) const case UnaryOp::BitNot: return bit_not(lhs_result); case UnaryOp::Not: - return Value(!lhs_result.as_bool()); + return Value(!lhs_result.to_boolean()); } ASSERT_NOT_REACHED();