[commit: ghc] wip/T10180: New Lint check: no alternatives implies exprIsBottom (b3fc549)

git at git.haskell.org git at git.haskell.org
Sun Mar 22 17:54:00 UTC 2015


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

On branch  : wip/T10180
Link       : http://ghc.haskell.org/trac/ghc/changeset/b3fc549eef9e5e15941e597dfa8c669ea33ff0cc/ghc

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

commit b3fc549eef9e5e15941e597dfa8c669ea33ff0cc
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Sun Mar 22 17:32:26 2015 +0100

    New Lint check: no alternatives implies exprIsBottom
    
    as suggested by SPJ. This fixes #10180.


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

b3fc549eef9e5e15941e597dfa8c669ea33ff0cc
 compiler/coreSyn/CoreLint.hs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index 690836a..5ff2f92 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -637,8 +637,12 @@ lintCoreExpr e@(Case scrut var alt_ty alts) =
      ; alt_ty   <- lintInTy alt_ty
      ; var_ty   <- lintInTy (idType var)
 
-     ; checkL (not (null alts && exprIsHNF scrut))
+     ; when (null alts) $
+     do { checkL (not (exprIsHNF scrut))
           (ptext (sLit "No alternatives for a case scrutinee in head-normal form:") <+> ppr scrut)
+        ; checkL (exprIsBottom scrut)
+          (ptext (sLit "No alternatives for a case scrutinee not known to diverge for sure:") <+> ppr scrut)
+        }
 
      ; case tyConAppTyCon_maybe (idType var) of
          Just tycon



More information about the ghc-commits mailing list