From b8a6d313a9f20b756fc90845fdd530927686257d Mon Sep 17 00:00:00 2001 From: Oleg Grenrus <oleg.grenrus@iki.fi> Date: Tue, 7 Feb 2017 13:17:03 +0200 Subject: [PATCH] Add diagnostics to overflow errors --- Data/Array/Base.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Data/Array/Base.hs b/Data/Array/Base.hs index 43963ebe..3bf861f3 100644 --- a/Data/Array/Base.hs +++ b/Data/Array/Base.hs @@ -1354,13 +1354,15 @@ bOOL_SCALE, bOOL_WORD_SCALE, wORD_SCALE, dOUBLE_SCALE, fLOAT_SCALE :: Int# -> Int# bOOL_SCALE n# | 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 !(I# last#) = SIZEOF_HSWORD * 8 - 1 !res# = (n# +# last#) `uncheckedIShiftRA#` 3# bOOL_WORD_SCALE n# | 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 !(I# last#) = SIZEOF_HSWORD * 8 - 1 !res# = bOOL_INDEX (n# +# last#) @@ -1371,7 +1373,8 @@ fLOAT_SCALE n# = safe_scale scale# n# where !(I# scale#) = SIZEOF_HSFLOAT safe_scale :: Int# -> Int# -> Int# safe_scale scale# n# | 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 !res# = scale# *# n# !overflow = isTrue# (maxN# `divInt#` scale# <# n#) -- GitLab