math::overflow_* wrappers incorrectly don't allow distinct integers #2221.

This commit is contained in:
Christoffer Lerno
2025-06-21 13:28:45 +02:00
parent fa730e7ec2
commit a0497e9274
7 changed files with 111 additions and 8 deletions

View File

@@ -1117,7 +1117,7 @@ macro overflow_mul_helper(x, y) @local
@param [&out] out : "Where the result of the addition is stored"
@return "Whether the addition resulted in an integer overflow"
@require values::@is_same_type(a, b) : "a and b must be the same type"
@require values::@is_int(a) &&& values::@is_int(b) : "a and b must both be integers"
@require values::@is_flat_intlike(a) &&& values::@is_flat_intlike(b) : "a and b must both be integer or integer vector based"
@require $defined(*out) &&& values::@is_same_type(*out, a) : "out must be a pointer of the same type as a and b"
*>
macro bool overflow_add(a, b, out) => $$overflow_add(a, b, out);
@@ -1126,7 +1126,7 @@ macro bool overflow_add(a, b, out) => $$overflow_add(a, b, out);
@param [&out] out : "Where the result of the subtraction is stored"
@return "Whether the subtraction resulted in an integer overflow"
@require values::@is_same_type(a, b) : "a and b must be the same type"
@require values::@is_int(a) &&& values::@is_int(b) : "a and b must both be integers"
@require values::@is_flat_intlike(a) &&& values::@is_flat_intlike(b) : "a and b must both be integer or integer vector based"
@require $defined(*out) &&& values::@is_same_type(*out, a) : "out must be a pointer of the same type as a and b"
*>
macro bool overflow_sub(a, b, out) => $$overflow_sub(a, b, out);
@@ -1135,7 +1135,7 @@ macro bool overflow_sub(a, b, out) => $$overflow_sub(a, b, out);
@param [&out] out : "Where the result of the multiplication is stored"
@return "Whether the multiplication resulted in an integer overflow"
@require values::@is_same_type(a, b) : "a and b must be the same type"
@require values::@is_int(a) &&& values::@is_int(b) : "a and b must both be integers"
@require values::@is_flat_intlike(a) &&& values::@is_flat_intlike(b) : "a and b must both be integer or integer vector based"
@require $defined(*out) &&& values::@is_same_type(*out, a) : "out must be a pointer of the same type as a and b"
*>
macro bool overflow_mul(a, b, out) => $$overflow_mul(a, b, out);