Don't permit data types with return kind Constraint
authorRyan Scott <ryan.gl.scott@gmail.com>
Mon, 19 Mar 2018 16:06:41 +0000 (12:06 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 19 Mar 2018 16:06:45 +0000 (12:06 -0400)
commitf748c52997f61a9f58eccbf4b8df0a0c8c6887e5
treea6620f06cdbcf605d963a102e95c30959becb8fd
parentc3aea39678398fdf88166f30f0d01225a1874a32
Don't permit data types with return kind Constraint

Previously, GHC allowed all of the following:

```lang=haskell
data Foo1 :: Constraint
data family Foo2 :: Constraint
data family Foo3 :: k
data instance Foo3 :: Constraint
```

Yikes! This is because GHC was confusing `Type` with `Constraint`
due to careless use of the `isLiftedTypeKind` function. To respect
this distinction, I swapped `isLiftedTypeKind` out for
`tcIsStarKind`—which does respect this distinction—in the right
places.

Test Plan: make test TEST="T14048a T14048b T14048c"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: goldfire, rwbarton, thomie, carter

GHC Trac Issues: #14048

Differential Revision: https://phabricator.haskell.org/D4479
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcTyClsDecls.hs
testsuite/tests/typecheck/should_fail/T14048a.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T14048a.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T14048b.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T14048b.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T14048c.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T14048c.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T