[commit: ghc] master: Track type variable scope more carefully. (faec8d3)

git at git.haskell.org git at git.haskell.org
Mon Apr 2 02:44:14 UTC 2018


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

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

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

commit faec8d358985e5d0bf363bd96f23fe76c9e281f7
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date:   Mon Sep 4 22:27:17 2017 +0100

    Track type variable scope more carefully.
    
    The main job of this commit is to track more accurately the scope
    of tyvars introduced by user-written foralls. For example, it would
    be to have something like this:
    
      forall a. Int -> (forall k (b :: k). Proxy '[a, b]) -> Bool
    
    In that type, a's kind must be k, but k isn't in scope. We had a
    terrible way of doing this before (not worth repeating or describing
    here, but see the old tcImplicitTKBndrs and friends), but now
    we have a principled approach: make an Implication when kind-checking
    a forall. Doing so then hooks into the existing machinery for
    preventing skolem-escape, performing floating, etc. This also means
    that we bump the TcLevel whenever going into a forall.
    
    The new behavior is done in TcHsType.scopeTyVars, but see also
    TcHsType.tc{Im,Ex}plicitTKBndrs, which have undergone significant
    rewriting. There are several Notes near there to guide you. Of
    particular interest there is that Implication constraints can now
    have skolems that are out of order; this situation is reported in
    TcErrors.
    
    A major consequence of this is a slightly tweaked process for type-
    checking type declarations. The new Note [Use SigTvs in kind-checking
    pass] in TcTyClsDecls lays it out.
    
    The error message for dependent/should_fail/TypeSkolEscape has become
    noticeably worse. However, this is because the code in TcErrors goes to
    some length to preserve pre-8.0 error messages for kind errors. It's time
    to rip off that plaster and get rid of much of the kind-error-specific
    error messages. I tried this, and doing so led to a lovely error message
    for TypeSkolEscape. So: I'm accepting the error message quality regression
    for now, but will open up a new ticket to fix it, along with a larger
    error-message improvement I've been pondering. This applies also to
    dependent/should_fail/{BadTelescope2,T14066,T14066e}, polykinds/T11142.
    
    Other minor changes:
     - isUnliftedTypeKind didn't look for tuples and sums. It does now.
    
     - check_type used check_arg_type on both sides of an AppTy. But the left
       side of an AppTy isn't an arg, and this was causing a bad error message.
       I've changed it to use check_type on the left-hand side.
    
     - Some refactoring around when we print (TYPE blah) in error messages.
       The changes decrease the times when we do so, to good effect.
       Of course, this is still all controlled by
       -fprint-explicit-runtime-reps
    
    Fixes #14066 #14749
    
    Test cases: dependent/should_compile/{T14066a,T14749},
                dependent/should_fail/T14066{,c,d,e,f,g,h}


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

faec8d358985e5d0bf363bd96f23fe76c9e281f7
 compiler/basicTypes/DataCon.hs                     |   6 +-
 compiler/basicTypes/Var.hs                         |  10 +-
 compiler/deSugar/DsExpr.hs                         |   4 +-
 compiler/hsSyn/HsDecls.hs                          |  11 +-
 compiler/hsSyn/HsTypes.hs                          |   4 +-
 compiler/iface/IfaceType.hs                        |  38 +-
 compiler/iface/ToIface.hs                          |  17 +-
 compiler/nativeGen/RegAlloc/Liveness.hs            |   2 -
 compiler/prelude/PrelNames.hs                      |  10 +-
 compiler/typecheck/TcBinds.hs                      |  39 +-
 compiler/typecheck/TcClassDcl.hs                   |  13 +-
 compiler/typecheck/TcDeriv.hs                      |   3 +
 compiler/typecheck/TcEnv.hs                        |   8 +
 compiler/typecheck/TcErrors.hs                     | 118 ++-
 compiler/typecheck/TcEvidence.hs                   |  12 +-
 compiler/typecheck/TcHsSyn.hs                      |   1 +
 compiler/typecheck/TcHsType.hs                     | 816 ++++++++++++++-------
 compiler/typecheck/TcInstDcls.hs                   |   6 +-
 compiler/typecheck/TcInteract.hs                   |  22 +-
 compiler/typecheck/TcMType.hs                      |  53 +-
 compiler/typecheck/TcPat.hs                        |   4 +
 compiler/typecheck/TcPatSyn.hs                     |   2 +-
 compiler/typecheck/TcRnDriver.hs                   |   3 +-
 compiler/typecheck/TcRnMonad.hs                    |  38 +-
 compiler/typecheck/TcRnTypes.hs                    |  49 +-
 compiler/typecheck/TcSMonad.hs                     |  21 +-
 compiler/typecheck/TcSigs.hs                       |  95 ++-
 compiler/typecheck/TcSimplify.hs                   | 201 +++--
 compiler/typecheck/TcSplice.hs                     |   2 +-
 compiler/typecheck/TcTyClsDecls.hs                 | 518 +++++++------
 compiler/typecheck/TcType.hs                       |  74 +-
 compiler/typecheck/TcUnify.hs                      |  27 +-
 compiler/typecheck/TcValidity.hs                   | 127 ++--
 compiler/types/Coercion.hs                         |   3 +-
 compiler/types/TyCoRep.hs                          |   8 +-
 compiler/types/TyCoRep.hs-boot                     |   5 +-
 compiler/types/TyCon.hs                            |  52 +-
 compiler/types/Type.hs                             |  19 +
 compiler/utils/Bag.hs                              |  15 +-
 compiler/utils/Outputable.hs                       |   5 +
 docs/users_guide/glasgow_exts.rst                  |  27 +-
 testsuite/tests/codeGen/should_fail/T13233.stderr  |   4 +-
 .../InferDependency.hs                             |   0
 testsuite/tests/dependent/should_compile/T11635.hs |   2 +-
 .../tests/dependent/should_compile/T14066a.hs      |  82 +++
 .../tests/dependent/should_compile/T14066a.stderr  |   5 +
 .../should_compile/T14749.hs                       |   0
 testsuite/tests/dependent/should_compile/all.T     |   2 +
 .../dependent/should_fail/BadTelescope.stderr      |   5 +-
 .../dependent/should_fail/BadTelescope2.stderr     |  13 +-
 .../dependent/should_fail/BadTelescope3.stderr     |   2 +-
 .../dependent/should_fail/BadTelescope4.stderr     |   4 +-
 .../dependent/should_fail/InferDependency.stderr   |  10 +-
 .../tests/dependent/should_fail/T13601.stderr      |   3 +-
 .../tests/dependent/should_fail/T13780c.stderr     |   2 +-
 testsuite/tests/dependent/should_fail/T14066.hs    |  17 +
 .../tests/dependent/should_fail/T14066.stderr      |  11 +
 testsuite/tests/dependent/should_fail/T14066c.hs   |   9 +
 .../tests/dependent/should_fail/T14066c.stderr     |   6 +
 testsuite/tests/dependent/should_fail/T14066d.hs   |  17 +
 .../tests/dependent/should_fail/T14066d.stderr     |  21 +
 testsuite/tests/dependent/should_fail/T14066e.hs   |  13 +
 .../tests/dependent/should_fail/T14066e.stderr     |  11 +
 testsuite/tests/dependent/should_fail/T14066f.hs   |   8 +
 .../tests/dependent/should_fail/T14066f.stderr     |   6 +
 testsuite/tests/dependent/should_fail/T14066g.hs   |   9 +
 .../tests/dependent/should_fail/T14066g.stderr     |   7 +
 testsuite/tests/dependent/should_fail/T14066h.hs   |  11 +
 .../tests/dependent/should_fail/T14066h.stderr     |  16 +
 .../tests/dependent/should_fail/TypeSkolEscape.hs  |   1 +
 .../dependent/should_fail/TypeSkolEscape.stderr    |  10 +-
 testsuite/tests/dependent/should_fail/all.T        |  11 +-
 testsuite/tests/deriving/should_compile/T11732c.hs |   7 +-
 testsuite/tests/gadt/T12468.stderr                 |   4 +-
 testsuite/tests/ghci/scripts/T10248.stderr         |   4 +-
 testsuite/tests/ghci/scripts/T10249.stderr         |   4 +-
 testsuite/tests/ghci/scripts/T8353.stderr          |  20 +-
 .../tests/indexed-types/should_fail/T7938.stderr   |   2 +-
 .../tests/indexed-types/should_fail/T8129.stdout   |   1 -
 testsuite/tests/module/mod71.stderr                |   4 +-
 .../partial-sigs/should_compile/T12531.stderr      |   4 +-
 .../tests/partial-sigs/should_fail/T10615.stderr   |   6 +-
 .../tests/partial-sigs/should_fail/T11976.stderr   |  18 +-
 .../tests/partial-sigs/should_fail/T14040a.stderr  |  37 +-
 testsuite/tests/perf/haddock/all.T                 |   5 +-
 testsuite/tests/polykinds/SigTvKinds3.hs           |   9 +
 testsuite/tests/polykinds/SigTvKinds3.stderr       |   6 +
 testsuite/tests/polykinds/T11142.stderr            |   9 +-
 testsuite/tests/polykinds/T12593.stderr            |  59 +-
 testsuite/tests/polykinds/T13985.stderr            |   6 +-
 testsuite/tests/polykinds/T14563.hs                |   2 +-
 testsuite/tests/polykinds/T14846.stderr            |  25 +
 testsuite/tests/polykinds/T7230.stderr             |   4 +-
 testsuite/tests/polykinds/T8566.stderr             |   2 +-
 testsuite/tests/polykinds/T9222.stderr             |   2 +-
 testsuite/tests/polykinds/all.T                    |   6 +-
 testsuite/tests/th/T10267.stderr                   |  16 +-
 .../tests/typecheck/should_compile/T13050.stderr   |  30 +-
 testsuite/tests/typecheck/should_compile/T13343.hs |   2 +
 .../tests/typecheck/should_compile/T14590.stderr   |  40 +-
 .../tests/typecheck/should_compile/T2494.stderr    |   6 +-
 .../tests/typecheck/should_compile/T9497a.stderr   |   4 +-
 .../abstract_refinement_substitutions.stderr       | 244 ++++--
 testsuite/tests/typecheck/should_compile/all.T     |   1 -
 .../should_compile/hole_constraints.stderr         |  20 +-
 .../should_compile/hole_constraints_nested.stderr  |   4 +-
 .../tests/typecheck/should_compile/holes.stderr    |  26 +-
 .../tests/typecheck/should_compile/holes3.stderr   |  26 +-
 .../should_compile/refinement_substitutions.stderr | 190 ++++-
 .../should_compile/valid_substitutions.stderr      |  30 +-
 .../valid_substitutions_interactions.stderr        |   4 +-
 .../tests/typecheck/should_fail/T11355.stderr      |   2 +-
 .../tests/typecheck/should_fail/T12177.stderr      |  11 +-
 .../tests/typecheck/should_fail/T14350.stderr      |  27 +-
 testsuite/tests/typecheck/should_fail/T14607.hs    |   4 +
 .../tests/typecheck/should_fail/T14607.stderr      |  13 +-
 .../tests/typecheck/should_fail/T9497d.stderr      |   4 +-
 testsuite/tests/typecheck/should_fail/all.T        |   2 +-
 .../tests/typecheck/should_run/T9497a-run.stderr   |   4 +-
 .../tests/typecheck/should_run/T9497b-run.stderr   |   4 +-
 .../tests/typecheck/should_run/T9497c-run.stderr   |   4 +-
 121 files changed, 2509 insertions(+), 1261 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 faec8d358985e5d0bf363bd96f23fe76c9e281f7


More information about the ghc-commits mailing list