[commit: ghc] master, wip/deploy-docs, wip/packaging-fail, wip/run-nofib, wip/windows-32bit: Reject nested predicates in impredicativity checking (8d18a87)

git at git.haskell.org git at git.haskell.org
Thu Mar 21 17:01:29 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: master,wip/deploy-docs,wip/packaging-fail,wip/run-nofib,wip/windows-32bit
Link       : http://ghc.haskell.org/trac/ghc/changeset/8d18a873c5d7688c6e7d91efab6bb0d6f99393c6/ghc

>---------------------------------------------------------------

commit 8d18a873c5d7688c6e7d91efab6bb0d6f99393c6
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sun Mar 17 09:37:27 2019 -0400

    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.


>---------------------------------------------------------------

8d18a873c5d7688c6e7d91efab6bb0d6f99393c6
 compiler/typecheck/TcErrors.hs                     |  8 +--
 compiler/typecheck/TcUnify.hs                      | 78 ++++++++++++----------
 .../dependent/should_compile/dynamic-paper.hs      |  2 +-
 .../dependent/should_compile/dynamic-paper.stderr  |  2 +-
 .../tests/ghci.debugger/scripts/print027.stdout    | 12 ++--
 testsuite/tests/ghci/scripts/T12447.script         |  2 +-
 testsuite/tests/ghci/scripts/T14828.stdout         |  4 +-
 .../tests/indexed-types/should_compile/T4358.hs    |  2 +-
 .../tests/indexed-types/should_fail/T5934.stderr   |  2 +-
 testsuite/tests/polykinds/T11142.stderr            |  2 +-
 testsuite/tests/polykinds/T14270.hs                |  2 +-
 testsuite/tests/polykinds/T9569.hs                 |  2 +-
 testsuite/tests/th/T11452.stderr                   |  2 +-
 .../tests/typecheck/should_compile/T12427a.stderr  |  5 +-
 .../tests/typecheck/should_fail/T10194.stderr      | 10 +--
 testsuite/tests/typecheck/should_fail/T11514.hs    |  6 ++
 .../tests/typecheck/should_fail/T11514.stderr      |  9 +++
 .../tests/typecheck/should_fail/T12563.stderr      |  2 +-
 .../tests/typecheck/should_fail/T12589.stderr      |  2 +-
 testsuite/tests/typecheck/should_fail/all.T        |  1 +
 20 files changed, 88 insertions(+), 67 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 8d18a873c5d7688c6e7d91efab6bb0d6f99393c6


More information about the ghc-commits mailing list