diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2014-08-25 15:10:19 +0100 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-11-03 08:19:05 -0600 |
commit | b15432c826fdad27afc45be617c117876d9f3e08 (patch) | |
tree | 0cd29b46a88faef7a15f5657a6624f6c5f1286a1 | |
parent | 246c3807a71bfb7d4f982a1903c22e3c81d74d37 (diff) | |
download | haskell-b15432c826fdad27afc45be617c117876d9f3e08.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
(cherry picked from commit 8ff4671422090acf9146e3a90dd38e2c6f72aebb)
-rw-r--r-- | compiler/coreSyn/CoreLint.lhs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/coreSyn/CoreLint.lhs b/compiler/coreSyn/CoreLint.lhs index 8665ec4111..2689900549 100644 --- a/compiler/coreSyn/CoreLint.lhs +++ b/compiler/coreSyn/CoreLint.lhs @@ -727,13 +727,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 |