Skip to content

Commit

Permalink
Add Note [No alternatives lint check]
Browse files Browse the repository at this point in the history
in a follow up to #10180.
  • Loading branch information
nomeata committed Mar 23, 2015
1 parent 567db32 commit 8f08069
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions compiler/coreSyn/CoreLint.hs
Expand Up @@ -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)
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion compiler/coreSyn/CoreUtils.hs
Expand Up @@ -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
Expand Down

0 comments on commit 8f08069

Please sign in to comment.