diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 4eb3d39558..6bcbdeb6ac 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -132,7 +132,7 @@ public: } template - requires(SameAs, bool>) explicit Value(T value) + requires(IsSameIgnoringCV) explicit Value(T value) : m_type(Type::Boolean) { m_value.as_bool = value; @@ -150,18 +150,12 @@ public: } } - explicit Value(unsigned long value) - { - if (value > NumericLimits::max()) { - m_value.as_double = static_cast(value); - m_type = Type::Double; - } else { - m_value.as_i32 = static_cast(value); - m_type = Type::Int32; - } - } - - explicit Value(unsigned value) + // NOTE: A couple of integral types are excluded here: + // - i32 has its own dedicated Value constructor + // - i64 cannot safely be cast to a double + // - bool isn't a number type and has its own dedicated Value constructor + template + requires(IsIntegral && !IsSameIgnoringCV && !IsSameIgnoringCV && !IsSameIgnoringCV) explicit Value(T value) { if (value > NumericLimits::max()) { m_value.as_double = static_cast(value);