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.
Showing
- compiler/typecheck/TcErrors.hs 4 additions, 4 deletionscompiler/typecheck/TcErrors.hs
- compiler/typecheck/TcUnify.hs 41 additions, 37 deletionscompiler/typecheck/TcUnify.hs
- testsuite/tests/dependent/should_compile/dynamic-paper.hs 1 addition, 1 deletiontestsuite/tests/dependent/should_compile/dynamic-paper.hs
- testsuite/tests/dependent/should_compile/dynamic-paper.stderr 1 addition, 1 deletion...suite/tests/dependent/should_compile/dynamic-paper.stderr
- testsuite/tests/ghci.debugger/scripts/print027.stdout 6 additions, 6 deletionstestsuite/tests/ghci.debugger/scripts/print027.stdout
- testsuite/tests/ghci/scripts/T12447.script 1 addition, 1 deletiontestsuite/tests/ghci/scripts/T12447.script
- testsuite/tests/ghci/scripts/T14828.stdout 2 additions, 2 deletionstestsuite/tests/ghci/scripts/T14828.stdout
- testsuite/tests/indexed-types/should_compile/T4358.hs 2 additions, 2 deletionstestsuite/tests/indexed-types/should_compile/T4358.hs
- testsuite/tests/indexed-types/should_fail/T5934.stderr 1 addition, 1 deletiontestsuite/tests/indexed-types/should_fail/T5934.stderr
- testsuite/tests/polykinds/T11142.stderr 1 addition, 1 deletiontestsuite/tests/polykinds/T11142.stderr
- testsuite/tests/polykinds/T14270.hs 1 addition, 1 deletiontestsuite/tests/polykinds/T14270.hs
- testsuite/tests/polykinds/T9569.hs 1 addition, 1 deletiontestsuite/tests/polykinds/T9569.hs
- testsuite/tests/th/T11452.stderr 1 addition, 1 deletiontestsuite/tests/th/T11452.stderr
- testsuite/tests/typecheck/should_compile/T12427a.stderr 3 additions, 2 deletionstestsuite/tests/typecheck/should_compile/T12427a.stderr
- testsuite/tests/typecheck/should_fail/T10194.stderr 5 additions, 5 deletionstestsuite/tests/typecheck/should_fail/T10194.stderr
- testsuite/tests/typecheck/should_fail/T11514.hs 6 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T11514.hs
- testsuite/tests/typecheck/should_fail/T11514.stderr 9 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T11514.stderr
- testsuite/tests/typecheck/should_fail/T12563.stderr 1 addition, 1 deletiontestsuite/tests/typecheck/should_fail/T12563.stderr
- testsuite/tests/typecheck/should_fail/T12589.stderr 1 addition, 1 deletiontestsuite/tests/typecheck/should_fail/T12589.stderr
- testsuite/tests/typecheck/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_fail/all.T
Loading
Please register or sign in to comment