avoid deprecation warnings on Nim 1.6 when using (#121)

This commit is contained in:
tersec 2023-02-07 13:41:40 +01:00 committed by GitHub
parent f36623998f
commit 3472a16fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -229,6 +229,9 @@ func divmodBS(x, y: UintImpl, q, r: var UintImpl) =
const BinaryShiftThreshold = 8 # If the difference in bit-length is below 8
# binary shift is probably faster
# TODO remove when stint removes Nim 1.2 support
import stew/shims/stddefects
func divmod*[T](x, y: UintImpl[T]): tuple[quot, rem: UintImpl[T]]=
let x_clz = x.leadingZeros
@ -237,7 +240,7 @@ func divmod*[T](x, y: UintImpl[T]): tuple[quot, rem: UintImpl[T]]=
# We short-circuit division depending on special-cases.
# TODO: Constant-time division
if unlikely(y.isZero):
raise newException(DivByZeroError, "You attempted to divide by zero")
raise newException(DivByZeroDefect, "You attempted to divide by zero")
elif y_clz == (bitsof(y) - 1):
# y is one
result.quot = x