Wrapping remainder for unsigned integer modulo
@@ -219,13 +219,16 @@ impl Expr {
if overflowed {
Err(SemanticError::ConstOverflow {
- is_positive: value.is_negative()
- }.into())
+ is_positive: value.is_negative(),
+ }
+ .into())
} else {
Ok(Some(Int(value)))
}
- },
- (UnsignedInt(a), UnsignedInt(b)) => Ok(Some(UnsignedInt(a % b))),
+ }
+ (UnsignedInt(a), UnsignedInt(b)) => {
+ Ok(Some(UnsignedInt(a.wrapping_rem(*b))))
+ }
(Char(a), Char(b)) => Ok(Some(Char(a % b))),
(_, _) => Ok(None),
},
