diff options
author | Rupert Horlick <ruperthorlick@gmail.com> | 2017-03-06 13:43:34 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-06 17:23:01 -0500 |
commit | 3fdabe9873e311571f614d455d1b16bc3f4fdc0f (patch) | |
tree | 4ea10e682a014f677c86beb02d7e63dedcfb9540 /compiler | |
parent | 016b10c50e365ca62a9baffa1c590f4efa8db409 (diff) | |
download | haskell-3fdabe9873e311571f614d455d1b16bc3f4fdc0f.tar.gz |
Changed OverLit warnings to work with negative literals (#13257)
Test Plan: Validate, check generated warnings
Reviewers: austin, bgamari, dfeuer
Reviewed By: bgamari, dfeuer
Subscribers: dfeuer, thomie
Differential Revision: https://phabricator.haskell.org/D3281
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/deSugar/DsExpr.hs | 9 | ||||
-rw-r--r-- | compiler/deSugar/MatchLit.hs | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs index 28254c93b4..faf562e428 100644 --- a/compiler/deSugar/DsExpr.hs +++ b/compiler/deSugar/DsExpr.hs @@ -271,6 +271,15 @@ dsExpr (HsWrap co_fn e) ; warnAboutIdentities dflags e' (exprType wrapped_e) ; return wrapped_e } +dsExpr (NegApp (L loc (HsOverLit lit@(OverLit { ol_val = HsIntegral src i }))) + neg_expr) + = do { expr' <- putSrcSpanDs loc $ do + { dflags <- getDynFlags + ; warnAboutOverflowedLiterals dflags + (lit { ol_val = HsIntegral src (-i) }) + ; dsOverLit' dflags lit } + ; dsSyntaxExpr neg_expr [expr'] } + dsExpr (NegApp expr neg_expr) = do { expr' <- dsLExpr expr ; dsSyntaxExpr neg_expr [expr'] } diff --git a/compiler/deSugar/MatchLit.hs b/compiler/deSugar/MatchLit.hs index 2e9a5235bf..6ed34f42db 100644 --- a/compiler/deSugar/MatchLit.hs +++ b/compiler/deSugar/MatchLit.hs @@ -8,10 +8,11 @@ Pattern-matching literal patterns {-# LANGUAGE CPP, ScopedTypeVariables #-} -module MatchLit ( dsLit, dsOverLit, hsLitKey +module MatchLit ( dsLit, dsOverLit, dsOverLit', hsLitKey , tidyLitPat, tidyNPat , matchLiterals, matchNPlusKPats, matchNPats - , warnAboutIdentities, warnAboutEmptyEnumerations + , warnAboutIdentities, warnAboutOverflowedLiterals + , warnAboutEmptyEnumerations ) where #include "HsVersions.h" |