summaryrefslogtreecommitdiff
path: root/compiler/coreSyn
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2015-03-23 22:16:08 +0100
committerJoachim Breitner <mail@joachim-breitner.de>2015-03-23 22:16:08 +0100
commit8f08069668f12ce019be3277bc4baacb477a77ed (patch)
tree61f19bb9a9e6d4d0b3528b06bdde89e5a9d40a3a /compiler/coreSyn
parent567db32b074860723e2b7c38f119b1880a803775 (diff)
downloadhaskell-8f08069668f12ce019be3277bc4baacb477a77ed.tar.gz
Add Note [No alternatives lint check]
in a follow up to #10180.
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r--compiler/coreSyn/CoreLint.hs13
-rw-r--r--compiler/coreSyn/CoreUtils.hs5
2 files changed, 17 insertions, 1 deletions
diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index c454334d46..d5b031ace5 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -657,6 +657,7 @@ lintCoreExpr e@(Case scrut var alt_ty alts) =
; alt_ty <- lintInTy alt_ty
; var_ty <- lintInTy (idType var)
+ -- See Note [No alternatives lint check]
; when (null alts) $
do { checkL (not (exprIsHNF scrut))
(ptext (sLit "No alternatives for a case scrutinee in head-normal form:") <+> ppr scrut)
@@ -715,6 +716,18 @@ kind coercions and produce the following substitution which is to be
applied in the type variables:
k_ag ~~> * -> *
+Note [No alternatives lint check]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Case expressions with no alternatives are odd beasts, and worth looking at
+in the linter.
+
+Certainly, it would be terribly wrong if the scrutinee was already in head
+normal form. That is the first check.
+
+Furthermore, we should be able to see why GHC believes the scrutinee is
+diverging for sure. That is the second check. see #10180.
+
************************************************************************
* *
\subsection[lintCoreArgs]{lintCoreArgs}
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index 46d4f58c5b..e0d94c4494 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -2108,7 +2108,10 @@ rhsIsStatic platform is_dynamic_name cvt_integer rhs = is_static False rhs
************************************************************************
-}
--- | True if the type has no non-bottom elements
+-- | True if the type has no non-bottom elements, e.g. when it is an empty
+-- datatype, or a GADT with non-satisfiable type parameters, e.g. Int :~: Bool.
+--
+-- See Note [No alternatives lint check] for one use of this function.
isEmptyTy :: Type -> Bool
isEmptyTy ty
-- Data types with no constructors are empty