[commit: ghc] master: exprIsBottom: Make use of isEmptyTy (#10186) (7062ebe)
git at git.haskell.org
git at git.haskell.org
Tue Mar 24 08:26:18 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/7062ebe0ce92c191d87e993bd2497275976b9452/ghc
>---------------------------------------------------------------
commit 7062ebe0ce92c191d87e993bd2497275976b9452
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Mon Mar 23 22:25:24 2015 +0100
exprIsBottom: Make use of isEmptyTy (#10186)
Any expression with of empty type is necessary bottom, so we can use
that here. No effects known, but it is the right thing to do and
validate, so lets do it.
Differential Revision: https://phabricator.haskell.org/D754
>---------------------------------------------------------------
7062ebe0ce92c191d87e993bd2497275976b9452
compiler/coreSyn/CoreLint.hs | 2 +-
compiler/coreSyn/CoreUtils.hs | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index d5b031a..81e5618 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -661,7 +661,7 @@ lintCoreExpr e@(Case scrut var alt_ty alts) =
; 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 || isEmptyTy (exprType scrut))
+ ; checkL (exprIsBottom scrut)
(ptext (sLit "No alternatives for a case scrutinee not known to diverge for sure:") <+> ppr scrut)
}
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index ba40f25..f400ebc 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -694,6 +694,10 @@ expensive.
-}
exprIsBottom :: CoreExpr -> Bool
+-- If the type only contains no elements besides bottom, then this expressions,
+-- well, bottom.
+exprIsBottom e | isEmptyTy (exprType e) = True
+-- Otherwise see if this is a bottoming id applied to enough arguments
exprIsBottom e
= go 0 e
where
More information about the ghc-commits
mailing list