[commit: ghc] wip/rae: Improve error messages around kind mismatches. (5836e65)

git at git.haskell.org git at git.haskell.org
Wed Jul 26 14:10:25 UTC 2017


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

On branch  : wip/rae
Link       : http://ghc.haskell.org/trac/ghc/changeset/5836e6504c4e4bee65d514a64c1f47ed353a74dd/ghc

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

commit 5836e6504c4e4bee65d514a64c1f47ed353a74dd
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date:   Thu Jun 1 17:27:14 2017 -0400

    Improve error messages around kind mismatches.
    
    Previously, when canonicalizing (or unifying, in uType) a
    heterogeneous equality, we emitted a kind equality and used the
    resulting coercion to cast one side of the heterogeneous equality.
    
    While sound, this led to terrible error messages. (See the bugs
    listed below.) The problem is that using the coercion built from
    the emitted kind equality is a bit like a wanted rewriting a wanted.
    The solution is to keep heterogeneous equalities as irreducible.
    
    See Note [Equalities with incompatible kinds] in TcCanonical.
    
    This commit also removes a highly suspicious switch to FM_SubstOnly
    when flattening in the kinds of a type variable. I have no idea
    why this was there, other than as a holdover from pre-TypeInType.
    I've not left a Note because there is simply no reason I can conceive
    of that the FM_SubstOnly should be there.
    
    One challenge with this patch is that the emitted derived equalities
    might get emitted several times: when a heterogeneous equality is
    in an implication and then gets floated out from the implication,
    the Derived is present both in and out of the implication. This
    causes a duplicate error message. (Test case:
    typecheck/should_fail/T7368) Solution: track the provenance of
    Derived constraints and refuse to float out a constraint that has
    an insoluble Derived.
    
    Lastly, this labels one test (dependent/should_fail/RAE_T32a)
    as expect_broken, because the problem is really #12919. The
    different handling of constraints in this patch exposes the error.
    
    This fixes bugs #11198, #12373, #13530, and #13610.
    
    test cases:
    typecheck/should_fail/{T8262,T8603,tcail122,T12373,T13530,T13610}


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

5836e6504c4e4bee65d514a64c1f47ed353a74dd
 compiler/typecheck/TcCanonical.hs                  | 296 ++++++++++++---------
 compiler/typecheck/TcErrors.hs                     |  75 ++++--
 compiler/typecheck/TcEvidence.hs                   |   8 +-
 compiler/typecheck/TcFlatten.hs                    |  31 ++-
 compiler/typecheck/TcRnTypes.hs                    |  30 ++-
 compiler/typecheck/TcSimplify.hs                   |  34 ++-
 compiler/typecheck/TcType.hs                       |  10 +-
 compiler/typecheck/TcUnify.hs                      |  28 +-
 compiler/types/Type.hs                             |   4 +-
 testsuite/tests/dependent/should_fail/T11471.hs    |   2 +-
 .../tests/dependent/should_fail/T11471.stderr      |  11 +-
 testsuite/tests/dependent/should_fail/all.T        |   2 +-
 testsuite/tests/gadt/gadt7.stderr                  |   6 +-
 .../tests/ghci.debugger/scripts/break012.stdout    |  14 +-
 .../indexed-types/should_fail/ExtraTcsUntch.stderr |   6 +-
 .../tests/indexed-types/should_fail/T5934.stderr   |  13 -
 testsuite/tests/polykinds/T12593.stderr            |  56 ++++
 testsuite/tests/polykinds/T13555.stderr            |  21 +-
 testsuite/tests/polykinds/T7438.stderr             |   6 +-
 testsuite/tests/polykinds/T8566.stderr             |   2 +-
 testsuite/tests/polykinds/T9017.stderr             |  10 +-
 testsuite/tests/typecheck/should_fail/T12373.hs    |  10 +
 .../tests/typecheck/should_fail/T12373.stderr      |   8 +
 testsuite/tests/typecheck/should_fail/T13530.hs    |  11 +
 .../tests/typecheck/should_fail/T13530.stderr      |   7 +
 testsuite/tests/typecheck/should_fail/T13610.hs    |  11 +
 .../tests/typecheck/should_fail/T13610.stderr      |  14 +
 testsuite/tests/typecheck/should_fail/T5691.stderr |  10 +-
 testsuite/tests/typecheck/should_fail/T7368.stderr |   6 +-
 .../tests/typecheck/should_fail/T7368a.stderr      |   2 +-
 testsuite/tests/typecheck/should_fail/T7453.stderr |  48 +---
 testsuite/tests/typecheck/should_fail/T7696.stderr |   4 +-
 testsuite/tests/typecheck/should_fail/T8262.stderr |   6 +-
 testsuite/tests/typecheck/should_fail/T8603.hs     |   4 +
 testsuite/tests/typecheck/should_fail/T8603.stderr |  13 +-
 testsuite/tests/typecheck/should_fail/all.T        |   3 +
 .../tests/typecheck/should_fail/tcfail090.stderr   |   4 +-
 .../tests/typecheck/should_fail/tcfail122.stderr   |   8 +-
 .../tests/typecheck/should_fail/tcfail123.stderr   |  13 +-
 .../tests/typecheck/should_fail/tcfail200.stderr   |   6 +-
 40 files changed, 537 insertions(+), 316 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 5836e6504c4e4bee65d514a64c1f47ed353a74dd


More information about the ghc-commits mailing list