Fix #16002 by moving a validity check to the renamer
authorRyan Scott <ryan.gl.scott@gmail.com>
Fri, 21 Dec 2018 04:00:21 +0000 (23:00 -0500)
committerRyan Scott <ryan.gl.scott@gmail.com>
Fri, 21 Dec 2018 04:00:21 +0000 (23:00 -0500)
commit28f41f1a7a0ebae7b50ca41dbf78c04ee5b8b5b7
tree6b67b7d02b2b69edd650c74a7f69e6c1281da80a
parent5f2a8793514918eaa670347ce0d95dfdbbdd4f4d
Fix #16002 by moving a validity check to the renamer

Summary:
The validity check which rejected things like:

```lang=haskell
type family B x where
  A x = x
```

Used to live in the typechecker. But it turns out that this validity
check was //only// being run on closed type families without CUSKs!
This meant that GHC would silently accept something like this:

```lang=haskell
type family B (x :: *) :: * where
  A x = x
```

This patch fixes the issue by moving this validity check to the
renamer, where we can be sure that the check will //always// be run.

Test Plan: make test TEST=T16002

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: goldfire, rwbarton, carter

GHC Trac Issues: #16002

Differential Revision: https://phabricator.haskell.org/D5420
compiler/rename/RnSource.hs
compiler/typecheck/TcTyClsDecls.hs
testsuite/tests/indexed-types/should_fail/Overlap5.stderr
testsuite/tests/rename/should_fail/T16002.hs [new file with mode: 0644]
testsuite/tests/rename/should_fail/T16002.stderr [new file with mode: 0644]
testsuite/tests/rename/should_fail/all.T
testsuite/tests/typecheck/should_fail/T11623.stderr