summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-08-25 15:10:19 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-08-25 15:18:05 +0100
commit8ff4671422090acf9146e3a90dd38e2c6f72aebb (patch)
tree98a2f5f7be42b18cee5563bda4bf743ce3a22034
parent5c4df28831fe40493f6b4d2577c255198774eeca (diff)
downloadhaskell-8ff4671422090acf9146e3a90dd38e2c6f72aebb.tar.gz
Make Core Lint check for un-saturated type applications
Un-saturated type-family and type-synonym applications are detected in the front end, but for some reason Lint wasn't looking for them. I came across this when wondering why Trac #9433 didn't give a Core Lint error
-rw-r--r--compiler/coreSyn/CoreLint.lhs15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/coreSyn/CoreLint.lhs b/compiler/coreSyn/CoreLint.lhs
index f4607823a8..21e0b5fefd 100644
--- a/compiler/coreSyn/CoreLint.lhs
+++ b/compiler/coreSyn/CoreLint.lhs
@@ -726,13 +726,20 @@ lintType ty@(FunTy t1 t2) -- (->) has two different rules, for types and kind
; lintArrow (ptext (sLit "type or kind") <+> quotes (ppr ty)) k1 k2 }
lintType ty@(TyConApp tc tys)
- | not (isUnLiftedTyCon tc) || tys `lengthIs` tyConArity tc
- -- Check that primitive types are saturated
+ | Just ty' <- coreView ty
+ = lintType ty' -- Expand type synonyms, so that we do not bogusly complain
+ -- about un-saturated type synonyms
+ --
+
+ | isUnLiftedTyCon tc || isSynTyCon tc
-- See Note [The kind invariant] in TypeRep
+ -- Also type synonyms and type families
+ , length tys < tyConArity tc
+ = failWithL (hang (ptext (sLit "Un-saturated type application")) 2 (ppr ty))
+
+ | otherwise
= do { ks <- mapM lintType tys
; lint_ty_app ty (tyConKind tc) (tys `zip` ks) }
- | otherwise
- = failWithL (hang (ptext (sLit "Malformed type:")) 2 (ppr ty))
lintType (ForAllTy tv ty)
= do { lintTyBndrKind tv