diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 390f5e4cee..e969cdab06 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -982,9 +982,9 @@ static void array_merge_sort(VM& vm, GlobalObject& global_object, FunctionObject // Because they are called with primitive strings, these is_less_than calls // should never result in a VM exception. - auto x_lt_y_relation = is_less_than(global_object, true, x_string_value, y_string_value); + auto x_lt_y_relation = MUST(is_less_than(global_object, true, x_string_value, y_string_value)); VERIFY(x_lt_y_relation != TriState::Unknown); - auto y_lt_x_relation = is_less_than(global_object, true, y_string_value, x_string_value); + auto y_lt_x_relation = MUST(is_less_than(global_object, true, y_string_value, x_string_value)); VERIFY(y_lt_x_relation != TriState::Unknown); if (x_lt_y_relation == TriState::True) { diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index d19b9916ba..ed4ee00680 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -771,7 +771,7 @@ ThrowCompletionOr Value::get_method(GlobalObject& global_object // 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators Value greater_than(GlobalObject& global_object, Value lhs, Value rhs) { - TriState relation = is_less_than(global_object, false, lhs, rhs); + TriState relation = TRY_OR_DISCARD(is_less_than(global_object, false, lhs, rhs)); if (relation == TriState::Unknown) return Value(false); return Value(relation == TriState::True); @@ -780,7 +780,7 @@ Value greater_than(GlobalObject& global_object, Value lhs, Value rhs) // 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators Value greater_than_equals(GlobalObject& global_object, Value lhs, Value rhs) { - TriState relation = is_less_than(global_object, true, lhs, rhs); + TriState relation = TRY_OR_DISCARD(is_less_than(global_object, true, lhs, rhs)); if (relation == TriState::Unknown || relation == TriState::True) return Value(false); return Value(true); @@ -789,7 +789,7 @@ Value greater_than_equals(GlobalObject& global_object, Value lhs, Value rhs) // 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators Value less_than(GlobalObject& global_object, Value lhs, Value rhs) { - TriState relation = is_less_than(global_object, true, lhs, rhs); + TriState relation = TRY_OR_DISCARD(is_less_than(global_object, true, lhs, rhs)); if (relation == TriState::Unknown) return Value(false); return Value(relation == TriState::True); @@ -798,7 +798,7 @@ Value less_than(GlobalObject& global_object, Value lhs, Value rhs) // 13.10 Relational Operators, https://tc39.es/ecma262/#sec-relational-operators Value less_than_equals(GlobalObject& global_object, Value lhs, Value rhs) { - TriState relation = is_less_than(global_object, false, lhs, rhs); + TriState relation = TRY_OR_DISCARD(is_less_than(global_object, false, lhs, rhs)); if (relation == TriState::Unknown || relation == TriState::True) return Value(false); return Value(true); @@ -1376,17 +1376,17 @@ bool is_loosely_equal(GlobalObject& global_object, Value lhs, Value rhs) } // 7.2.13 IsLessThan ( x, y, LeftFirst ), https://tc39.es/ecma262/#sec-islessthan -TriState is_less_than(GlobalObject& global_object, bool left_first, Value lhs, Value rhs) +ThrowCompletionOr is_less_than(GlobalObject& global_object, bool left_first, Value lhs, Value rhs) { Value x_primitive; Value y_primitive; if (left_first) { - x_primitive = TRY_OR_DISCARD(lhs.to_primitive(global_object, Value::PreferredType::Number)); - y_primitive = TRY_OR_DISCARD(rhs.to_primitive(global_object, Value::PreferredType::Number)); + x_primitive = TRY(lhs.to_primitive(global_object, Value::PreferredType::Number)); + y_primitive = TRY(rhs.to_primitive(global_object, Value::PreferredType::Number)); } else { - y_primitive = TRY_OR_DISCARD(lhs.to_primitive(global_object, Value::PreferredType::Number)); - x_primitive = TRY_OR_DISCARD(rhs.to_primitive(global_object, Value::PreferredType::Number)); + y_primitive = TRY(lhs.to_primitive(global_object, Value::PreferredType::Number)); + x_primitive = TRY(rhs.to_primitive(global_object, Value::PreferredType::Number)); } if (x_primitive.is_string() && y_primitive.is_string()) { @@ -1435,8 +1435,8 @@ TriState is_less_than(GlobalObject& global_object, bool left_first, Value lhs, V return TriState::False; } - auto x_numeric = TRY_OR_DISCARD(x_primitive.to_numeric(global_object)); - auto y_numeric = TRY_OR_DISCARD(y_primitive.to_numeric(global_object)); + auto x_numeric = TRY(x_primitive.to_numeric(global_object)); + auto y_numeric = TRY(y_primitive.to_numeric(global_object)); if (x_numeric.is_nan() || y_numeric.is_nan()) return TriState::Unknown; diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index f0bac9cfcf..af84ab884a 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -427,7 +427,7 @@ bool is_strictly_equal(Value lhs, Value rhs); bool same_value(Value lhs, Value rhs); bool same_value_zero(Value lhs, Value rhs); bool same_value_non_numeric(Value lhs, Value rhs); -TriState is_less_than(GlobalObject&, bool left_first, Value lhs, Value rhs); +ThrowCompletionOr is_less_than(GlobalObject&, bool left_first, Value lhs, Value rhs); inline bool Value::operator==(Value const& value) const { return same_value(*this, value); }