Fix X is gcd(1, 2 ^ 64) triggering a panic

The implementation for gcd/2 would cast the second argument to an isize.
This commit is contained in:
Emilie Burgun
2025-01-20 11:10:16 +01:00
parent d3361c16d8
commit e2d1a2b6bc

View File

@@ -947,8 +947,7 @@ pub(crate) fn gcd(n1: Number, n2: Number, arena: &mut Arena) -> Result<Number, M
Ok(Number::arena_from(Integer::from(n2_clone.gcd(&n1)), arena))
}
(Number::Integer(n1), Number::Integer(n2)) => {
let n2: isize = (&*n2).try_into().unwrap();
let value: Integer = (&*n1).gcd(&Integer::from(n2)).into();
let value: Integer = (&*n1).gcd(&*n2).into();
Ok(Number::arena_from(value, arena))
}
(Number::Float(f), _) | (_, Number::Float(f)) => {