summaryrefslogtreecommitdiff
path: root/testsuite/tests/warnings/should_compile/Overflow.hs
blob: 7029b7aaa8c2617bf9db58ed2eddba0daad8bf4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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