diff --git a/AK/DistinctNumeric.h b/AK/DistinctNumeric.h index 1e0525ae7e9..a106cb9a033 100644 --- a/AK/DistinctNumeric.h +++ b/AK/DistinctNumeric.h @@ -286,8 +286,8 @@ public: } constexpr Self& operator-=(Self const& other) { - static_assert(options.arithmetic, "'a+=b' is only available for DistinctNumeric types with 'Arithmetic'."); - this->m_value += other.m_value; + static_assert(options.arithmetic, "'a-=b' is only available for DistinctNumeric types with 'Arithmetic'."); + this->m_value -= other.m_value; return *this; } constexpr Self& operator*=(Self const& other) diff --git a/Tests/AK/TestDistinctNumeric.cpp b/Tests/AK/TestDistinctNumeric.cpp index e8b398b7402..210faee8e5e 100644 --- a/Tests/AK/TestDistinctNumeric.cpp +++ b/Tests/AK/TestDistinctNumeric.cpp @@ -197,6 +197,10 @@ TEST_CASE(operator_arith) EXPECT_EQ(a, ArithNumeric(1)); EXPECT_EQ(a %= a, ArithNumeric(0)); EXPECT_EQ(a, ArithNumeric(0)); + + a = ArithNumeric(12); + EXPECT_EQ(a -= a, ArithNumeric(0)); + EXPECT_EQ(a, ArithNumeric(0)); } TEST_CASE(composability)