summaryrefslogtreecommitdiff
path: root/libraries/base
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-12-03 07:03:44 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2018-12-03 07:03:44 -0500
commit75a8349b2a7d0142d3d687837caf5a95bbb4368d (patch)
tree7a1c14b1ba4357dcc032d2d32a10039b8c3f1cd0 /libraries/base
parent93a3f9070d5d69ad6a28fe94ccccd20c54609698 (diff)
downloadhaskell-75a8349b2a7d0142d3d687837caf5a95bbb4368d.tar.gz
Warn on all out-of-range literals in pats/exprs
Summary: These changes were motivated by #13256. While poking around, I realized we weren't very consistent in our "-Woverflowed-literals" warnings. This patch fixes that by: * warning earlier on in the pipeline (ie. before we've desugared 'Int' patterns into 'I# Int#') * handling 'HsLit' as well as 'HsOverLit' (this covers unboxed literals) * covering more pattern / expression forms 4/6 of the warnings in the 'Overflow' test are due to this patch. The other two are mostly for completeness. Also fixed a missing empty-enumeration warning for 'Natural'. This warnings were tripped up by the 'Bounded Word' instance (see #9505), but the fix was obvious and simple: use unboxed word literals. Test Plan: make TEST=Overflow && make TEST=T10930 Reviewers: hvr, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, carter GHC Trac Issues: #13256, #10930 Differential Revision: https://phabricator.haskell.org/D5181
Diffstat (limited to 'libraries/base')
-rw-r--r--libraries/base/GHC/Enum.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/base/GHC/Enum.hs b/libraries/base/GHC/Enum.hs
index af74f7c984..1b64eaf668 100644
--- a/libraries/base/GHC/Enum.hs
+++ b/libraries/base/GHC/Enum.hs
@@ -632,9 +632,9 @@ instance Bounded Word where
-- use unboxed literals for maxBound, because GHC doesn't optimise
-- (fromInteger 0xffffffff :: Word).
#if WORD_SIZE_IN_BITS == 32
- maxBound = W# (int2Word# 0xFFFFFFFF#)
+ maxBound = W# 0xFFFFFFFF##
#elif WORD_SIZE_IN_BITS == 64
- maxBound = W# (int2Word# 0xFFFFFFFFFFFFFFFF#)
+ maxBound = W# 0xFFFFFFFFFFFFFFFF##
#else
#error Unhandled value for WORD_SIZE_IN_BITS
#endif