Skip to content
Snippets Groups Projects
Commit b8a6d313 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by Ben Gamari
Browse files

Add diagnostics to overflow errors

parent 6e110fe4
No related branches found
No related tags found
1 merge request!2Bring mirror up-to-date and bump base upper bound
...@@ -1354,13 +1354,15 @@ bOOL_SCALE, bOOL_WORD_SCALE, ...@@ -1354,13 +1354,15 @@ bOOL_SCALE, bOOL_WORD_SCALE,
wORD_SCALE, dOUBLE_SCALE, fLOAT_SCALE :: Int# -> Int# wORD_SCALE, dOUBLE_SCALE, fLOAT_SCALE :: Int# -> Int#
bOOL_SCALE n# bOOL_SCALE n#
| isTrue# (res# ># n#) = res# | isTrue# (res# ># n#) = res#
| otherwise = error "Data.Array.Base.bOOL_SCALE: Overflow" | otherwise = error $ "Data.Array.Base.bOOL_SCALE: Overflow; n: "
++ show (I# n#) ++ ", res: " ++ show (I# n#)
where where
!(I# last#) = SIZEOF_HSWORD * 8 - 1 !(I# last#) = SIZEOF_HSWORD * 8 - 1
!res# = (n# +# last#) `uncheckedIShiftRA#` 3# !res# = (n# +# last#) `uncheckedIShiftRA#` 3#
bOOL_WORD_SCALE n# bOOL_WORD_SCALE n#
| isTrue# (res# ># n#) = res# | isTrue# (res# ># n#) = res#
| otherwise = error "Data.Array.Base.bOOL_WORD_SCALE: Overflow" | otherwise = error $ "Data.Array.Base.bOOL_WORD_SCALE: Overflow; n: "
++ show (I# n#) ++ ", res: " ++ show (I# n#)
where where
!(I# last#) = SIZEOF_HSWORD * 8 - 1 !(I# last#) = SIZEOF_HSWORD * 8 - 1
!res# = bOOL_INDEX (n# +# last#) !res# = bOOL_INDEX (n# +# last#)
...@@ -1371,7 +1373,8 @@ fLOAT_SCALE n# = safe_scale scale# n# where !(I# scale#) = SIZEOF_HSFLOAT ...@@ -1371,7 +1373,8 @@ fLOAT_SCALE n# = safe_scale scale# n# where !(I# scale#) = SIZEOF_HSFLOAT
safe_scale :: Int# -> Int# -> Int# safe_scale :: Int# -> Int# -> Int#
safe_scale scale# n# safe_scale scale# n#
| not overflow = res# | not overflow = res#
| otherwise = error "Data.Array.Base.safe_scale: Overflow" | otherwise = error $ "Data.Array.Base.safe_scale: Overflow; scale: "
++ show (I# scale#) ++ ", n: " ++ show (I# n#)
where where
!res# = scale# *# n# !res# = scale# *# n#
!overflow = isTrue# (maxN# `divInt#` scale# <# n#) !overflow = isTrue# (maxN# `divInt#` scale# <# n#)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment