Actually fix negative check

This commit is contained in:
carbotaniuman committed 2020-11-18 09:15:19 -06:00
1 parent b97aa409ef
commit 2277f41827
1 file changed
+7 -4
+7 -4
View File
@@ -425,10 +425,13 @@ impl PyInt {
if modulus.is_zero() {
return Err(vm.new_value_error("pow() 3rd argument cannot be 0".to_owned()));
}
if modulus.is_negative() {
return Err(vm.new_not_implemented_error("modular inverses".to_owned()));
}
self.general_op(other, |a, b| Ok(vm.ctx.new_int(a.modpow(b, modulus))), vm)
self.general_op(other, |a, b| {
if b.is_negative() {
Err(vm.new_not_implemented_error("modular inverses".to_owned()))
} else {
Ok(vm.ctx.new_int(a.modpow(b, modulus)))
}
}, vm)
}
None => self.general_op(other, |a, b| inner_pow(a, b, vm), vm),
}