diff options
Diffstat (limited to 'testsuite/tests/warnings/should_compile/Overflow.hs')
-rw-r--r-- | testsuite/tests/warnings/should_compile/Overflow.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/warnings/should_compile/Overflow.hs b/testsuite/tests/warnings/should_compile/Overflow.hs new file mode 100644 index 0000000000..7029b7aaa8 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/Overflow.hs @@ -0,0 +1,32 @@ +{-# LANGUAGE MagicHash #-} +module Overflow where + +import GHC.Exts + +-- Overflow an 'Int#' expression +f x = let y :: Int# + y = 10000000000000000000000000000000# + in 9 + +-- Overflow an 'Int#' pattern +g :: Int# -> Bool +g 100000000000000000000000000# = True +g _ = False + +-- Overflow an 'Int' expression +h :: Int +h = 1000000000000000000000000000000 + +-- Overflow an 'Int' pattern +i :: Int -> Int +i 100000000000000000000000000000000 = 0 +i _ = 1 + +-- Underflow a 'Word' expression +j :: Word +j = -1 + +-- Underflow a 'Word' pattern +k :: Word -> Bool +k (-1) = True +k _ = False |