Commit 7062ebe0 authored by Joachim Breitner's avatar Joachim Breitner
Browse files

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
parent fd176515
......@@ -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)
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment