[commit: ghc] master: Check that a default type signature aligns with the non-default signature (7363d53)

git at git.haskell.org git at git.haskell.org
Mon Jan 30 19:03:07 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7363d5380e600e2ef868a069d5df6857d9e5c17e/ghc

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

commit 7363d5380e600e2ef868a069d5df6857d9e5c17e
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Mon Jan 30 11:51:22 2017 -0500

    Check that a default type signature aligns with the non-default signature
    
    Before, GHC was extremely permissive about the form a default type
    signature could take on in a class declaration. Notably, it would accept
    garbage like this:
    
      class Monad m => MonadSupply m where
        fresh :: m Integer
        default fresh :: MonadTrans t => t m Integer
        fresh = lift fresh
    
    And then give an extremely confusing error message when you actually
    tried to declare an empty instance of MonadSupply. We now do extra
    validity checking of default type signatures to ensure that they align
    with their non-default type signature counterparts. That is, a default
    type signature is allowed to differ from the non-default one only in its
    context - they must otherwise be alpha-equivalent.
    
    Fixes #12918.
    
    Test Plan: ./validate
    
    Reviewers: goldfire, simonpj, austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: mpickering, dfeuer, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2983
    
    GHC Trac Issues: #12918


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

7363d5380e600e2ef868a069d5df6857d9e5c17e
 compiler/typecheck/Inst.hs                         |   4 +
 compiler/typecheck/TcTyClsDecls.hs                 | 212 ++++++++++++++++++++-
 compiler/typecheck/TcType.hs                       |  30 ++-
 docs/users_guide/8.2.1-notes.rst                   |   6 +
 docs/users_guide/glasgow_exts.rst                  |  53 ++++++
 testsuite/tests/generics/T10361b.hs                |   4 +-
 .../tests/typecheck/should_fail/T12151.stderr      |   6 +
 testsuite/tests/typecheck/should_fail/T12918a.hs   |   9 +
 .../tests/typecheck/should_fail/T12918a.stderr     |   8 +
 testsuite/tests/typecheck/should_fail/T12918b.hs   |  34 ++++
 .../tests/typecheck/should_fail/T12918b.stderr     |  41 ++++
 testsuite/tests/typecheck/should_fail/T7437.stderr |   8 +
 testsuite/tests/typecheck/should_fail/all.T        |   2 +
 13 files changed, 405 insertions(+), 12 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 7363d5380e600e2ef868a069d5df6857d9e5c17e


More information about the ghc-commits mailing list