Be pickier about unsaturated synonyms in :kind
authorRyan Scott <ryan.gl.scott@gmail.com>
Tue, 8 Jan 2019 12:37:18 +0000 (07:37 -0500)
committerRyan Scott <ryan.gl.scott@gmail.com>
Tue, 8 Jan 2019 12:37:18 +0000 (07:37 -0500)
commit6b70cf611e5ddc475edaa54b893d20990699ddb8
treeb8cacfce9a907079df9475a943caa9e7c8ce0085
parent6b5ec08a4a64525bae87a8c2202688ffc6f86aa8
Be pickier about unsaturated synonyms in :kind

Summary:
We currently permit any and all uses of unsaturated type
synonyms and type families in GHCi's `:kind` command, which allows
strange interactions like this one:

```
> :set -XTypeFamilies -XPolyKinds
> type family Id (a :: k)
> type instance Id a = a
> type Foo x = Maybe
> :kind! Id Foo
```

This is probably a stretch too far, so this patch moves to disallow
unsaturated synonyms that aren't at the top level (we still want to
allow `:kind Id`, for instance). We do this by augmenting `GhciCtxt`
with an additional `Bool` field to indicate if we are at the
outermost level of the type being passed to `:kind` or not. See
`Note [Unsaturated type synonyms in GHCi]` in `TcValidity` for the
full story.

Test Plan: make test TEST=T16013

Reviewers: goldfire, bgamari

Reviewed By: goldfire

Subscribers: simonpj, goldfire, rwbarton, carter

GHC Trac Issues: #16013

Differential Revision: https://phabricator.haskell.org/D5471
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
testsuite/tests/ghci/should_fail/T16013.script [new file with mode: 0644]
testsuite/tests/ghci/should_fail/T16013.stderr [new file with mode: 0644]
testsuite/tests/ghci/should_fail/all.T