diff options
author | Roland Senn <rsx@bluewin.ch> | 2020-06-17 17:18:26 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-25 03:54:48 -0400 |
commit | fe281b27d544920a2c2ddc00f6284006b85ab294 (patch) | |
tree | 60b47aea661bc80c8b3b714aaa212a95f13425a3 /compiler/GHC/HsToCore/Expr.hs | |
parent | c50ef26edaa537c0a13ac1a574632f9078c5671b (diff) | |
download | haskell-fe281b27d544920a2c2ddc00f6284006b85ab294.tar.gz |
Enable maxBound checks for OverloadedLists (Fixes #18172)
Consider the Literal `[256] :: [Data.Word.Word8]`
When the `OverloadedLists` extension is not active, then the `ol_ext` field
in the `OverLitTc` record that is passed to the function `getIntegralLit`
contains the type `Word8`. This is a simple type, and we can use its
type constructor immediately for the `warnAboutOverflowedLiterals` function.
When the `OverloadedLists` extension is active, then the `ol_ext` field
contains the type family `Item [Word8]`. The function `nomaliseType` is used
to convert it to the needed type `Word8`.
Diffstat (limited to 'compiler/GHC/HsToCore/Expr.hs')
-rw-r--r-- | compiler/GHC/HsToCore/Expr.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/GHC/HsToCore/Expr.hs b/compiler/GHC/HsToCore/Expr.hs index ff23a9c168..6b55926af3 100644 --- a/compiler/GHC/HsToCore/Expr.hs +++ b/compiler/GHC/HsToCore/Expr.hs @@ -945,8 +945,9 @@ dsArithSeq :: PostTcExpr -> (ArithSeqInfo GhcTc) -> DsM CoreExpr dsArithSeq expr (From from) = App <$> dsExpr expr <*> dsLExprNoLP from dsArithSeq expr (FromTo from to) - = do dflags <- getDynFlags - warnAboutEmptyEnumerations dflags from Nothing to + = do fam_envs <- dsGetFamInstEnvs + dflags <- getDynFlags + warnAboutEmptyEnumerations fam_envs dflags from Nothing to expr' <- dsExpr expr from' <- dsLExprNoLP from to' <- dsLExprNoLP to @@ -954,8 +955,9 @@ dsArithSeq expr (FromTo from to) dsArithSeq expr (FromThen from thn) = mkApps <$> dsExpr expr <*> mapM dsLExprNoLP [from, thn] dsArithSeq expr (FromThenTo from thn to) - = do dflags <- getDynFlags - warnAboutEmptyEnumerations dflags from (Just thn) to + = do fam_envs <- dsGetFamInstEnvs + dflags <- getDynFlags + warnAboutEmptyEnumerations fam_envs dflags from (Just thn) to expr' <- dsExpr expr from' <- dsLExprNoLP from thn' <- dsLExprNoLP thn |