diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-01-08 07:37:18 -0500 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-01-08 07:37:18 -0500 |
commit | 6b70cf611e5ddc475edaa54b893d20990699ddb8 (patch) | |
tree | b8cacfce9a907079df9475a943caa9e7c8ce0085 /testsuite/tests | |
parent | 6b5ec08a4a64525bae87a8c2202688ffc6f86aa8 (diff) | |
download | haskell-6b70cf611e5ddc475edaa54b893d20990699ddb8.tar.gz |
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
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/ghci/should_fail/T16013.script | 5 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_fail/T16013.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/should_fail/all.T | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/should_fail/T16013.script b/testsuite/tests/ghci/should_fail/T16013.script new file mode 100644 index 0000000000..287de60656 --- /dev/null +++ b/testsuite/tests/ghci/should_fail/T16013.script @@ -0,0 +1,5 @@ +:set -XTypeFamilies -XPolyKinds +type family Id (a :: k) +type instance Id a = a +type Foo x = Maybe +:kind! Id Foo diff --git a/testsuite/tests/ghci/should_fail/T16013.stderr b/testsuite/tests/ghci/should_fail/T16013.stderr new file mode 100644 index 0000000000..ec60359829 --- /dev/null +++ b/testsuite/tests/ghci/should_fail/T16013.stderr @@ -0,0 +1,3 @@ + +<interactive>:1:1: error: + The type synonym ‘Foo’ should have 1 argument, but has been given none diff --git a/testsuite/tests/ghci/should_fail/all.T b/testsuite/tests/ghci/should_fail/all.T index 01e5c36579..5e0a18c5b8 100644 --- a/testsuite/tests/ghci/should_fail/all.T +++ b/testsuite/tests/ghci/should_fail/all.T @@ -2,3 +2,4 @@ test('T10549', [], ghci_script, ['T10549.script']) test('T10549a', [], ghci_script, ['T10549a.script']) test('T14608', [], ghci_script, ['T14608.script']) test('T15055', normalise_version('ghc'), ghci_script, ['T15055.script']) +test('T16013', [], ghci_script, ['T16013.script']) |