[commit: ghc] master: Warn on all out-of-range literals in pats/exprs (75a8349)

git at git.haskell.org git at git.haskell.org
Mon Dec 3 12:47:27 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/75a8349b2a7d0142d3d687837caf5a95bbb4368d/ghc

>---------------------------------------------------------------

commit 75a8349b2a7d0142d3d687837caf5a95bbb4368d
Author: Alec Theriault <alec.theriault at gmail.com>
Date:   Mon Dec 3 07:03:44 2018 -0500

    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


>---------------------------------------------------------------

75a8349b2a7d0142d3d687837caf5a95bbb4368d
 compiler/deSugar/DsExpr.hs                         |  18 ++--
 compiler/deSugar/DsMonad.hs                        |  26 +++--
 compiler/deSugar/Match.hs                          | 120 ++++++++++++---------
 compiler/deSugar/MatchCon.hs                       |   4 +-
 compiler/deSugar/MatchLit.hs                       | 101 ++++++++++++-----
 compiler/prelude/TysPrim.hs                        |  16 +--
 docs/users_guide/8.8.1-notes.rst                   |   5 +
 libraries/base/GHC/Enum.hs                         |   4 +-
 .../tests/warnings/should_compile/Overflow.hs      |  32 ++++++
 .../tests/warnings/should_compile/Overflow.stderr  |  18 ++++
 testsuite/tests/warnings/should_compile/T10930.hs  |  10 ++
 .../tests/warnings/should_compile/T10930.stderr    |  11 ++
 testsuite/tests/warnings/should_compile/T10930b.hs |   7 ++
 .../tests/warnings/should_compile/T10930b.stderr   |  15 +++
 testsuite/tests/warnings/should_compile/T13256.hs  |   4 +
 .../tests/warnings/should_compile/T13256.stderr    |   3 +
 testsuite/tests/warnings/should_compile/T15460.hs  |   9 ++
 .../tests/warnings/should_compile/T15460.stderr    |   3 +
 testsuite/tests/warnings/should_compile/all.T      |   6 ++
 19 files changed, 314 insertions(+), 98 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 75a8349b2a7d0142d3d687837caf5a95bbb4368d


More information about the ghc-commits mailing list