diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-03-17 09:37:27 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-20 20:10:57 -0400 |
commit | 8d18a873c5d7688c6e7d91efab6bb0d6f99393c6 (patch) | |
tree | 9d66f0b2647ebd968ab9ec6d2cc0debe900da9a0 /testsuite/tests/indexed-types | |
parent | 646e3dc20ebe25baae898a6b22895ddd015fc975 (diff) | |
download | haskell-8d18a873c5d7688c6e7d91efab6bb0d6f99393c6.tar.gz |
Reject nested predicates in impredicativity checking
When GHC attempts to unify a metavariable with a type containing
foralls, it will be rejected as an occurrence of impredicativity.
GHC was /not/ extending the same treatment to predicate types, such
as in the following (erroneous) example from #11514:
```haskell
foo :: forall a. (Show a => a -> a) -> ()
foo = undefined
```
This will attempt to instantiate `undefined` at
`(Show a => a -> a) -> ()`, which is impredicative. This patch
catches impredicativity arising from predicates in this fashion.
Since GHC is pickier about impredicative instantiations, some test
cases needed to be updated to be updated so as not to fall afoul of
the new validity check. (There were a surprising number of
impredicative uses of `undefined`!) Moreover, the `T14828` test case
now has slightly less informative types shown with `:print`. This is
due to a a much deeper issue with the GHCi debugger (see #14828).
Fixes #11514.
Diffstat (limited to 'testsuite/tests/indexed-types')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/T4358.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/indexed-types/should_fail/T5934.stderr | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T4358.hs b/testsuite/tests/indexed-types/should_compile/T4358.hs index 0c05576812..cb05a1c1aa 100644 --- a/testsuite/tests/indexed-types/should_compile/T4358.hs +++ b/testsuite/tests/indexed-types/should_compile/T4358.hs @@ -6,6 +6,6 @@ type family T a t2 :: forall a. ((T a ~ a) => a) -> a t2 = t - + t :: forall a. ((T a ~ a) => a) -> a -t = undefined +t _ = undefined diff --git a/testsuite/tests/indexed-types/should_fail/T5934.stderr b/testsuite/tests/indexed-types/should_fail/T5934.stderr index 21af0d868a..e7448a9722 100644 --- a/testsuite/tests/indexed-types/should_fail/T5934.stderr +++ b/testsuite/tests/indexed-types/should_fail/T5934.stderr @@ -1,7 +1,7 @@ T5934.hs:12:7: error: • Cannot instantiate unification variable ‘a0’ - with a type involving foralls: (forall s. GenST s) -> Int + with a type involving polytypes: (forall s. GenST s) -> Int GHC doesn't yet support impredicative polymorphism • In the expression: 0 In an equation for ‘run’: run = 0 |