[commit: ghc] master: Improve kick-out in the constraint solver (3acd616)

git at git.haskell.org git at git.haskell.org
Fri Oct 20 12:02:02 UTC 2017


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

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

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

commit 3acd6164fea6d4d5d87521a291455a18c9c9a8ee
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Oct 20 12:08:04 2017 +0100

    Improve kick-out in the constraint solver
    
    This patch was provoked by Trac #14363.  Turned out that we were
    kicking out too many constraints in TcSMonad.kickOutRewritable, and
    that mean that the work-list never became empty: infinite loop!
    
    That in turn made me look harder at the Main Theorem in
    Note [Extending the inert equalities].
    
    Main changes
    
    * Replace TcType.isTyVarExposed by TcType.isTyVarHead.  The
      over-agressive isTyVarExposed is what caused Trac #14363.
      See Note [K3: completeness of solving] in TcSMonad.
    
    * TcType.Make anyRewriteableTyVar role-aware.  In particular,
          a ~R ty
      cannot rewrite
          b ~R f a
      See Note [anyRewriteableTyVar must be role-aware].  That means
      it has to be given a role argument, which forces a little
      refactoring.
    
      I think this change is fixing a bug that hasn't yet been reported.
      The actual reported bug is handled by the previous bullet.  But
      this change is definitely the Right Thing
    
    The main changes are in TcSMonad.kick_out_rewritable, and in TcType
    (isTyVarExposed ---> isTyVarHead).
    
    I did a little unforced refactoring:
    
     * Use the cc_eq_rel field of a CTyEqCan when it is available, rather
       than recomputing it.
    
     * Define eqCanRewrite :: EqRel -> EqRel -> EqRel, and use it, instead
       of duplicating its logic


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

3acd6164fea6d4d5d87521a291455a18c9c9a8ee
 compiler/typecheck/TcFlatten.hs                    |   7 +-
 compiler/typecheck/TcInteract.hs                   |  18 +--
 compiler/typecheck/TcRnTypes.hs                    |  36 +++--
 compiler/typecheck/TcSMonad.hs                     | 157 +++++++++++++--------
 compiler/typecheck/TcType.hs                       |  92 +++++++-----
 testsuite/tests/typecheck/should_compile/T14363.hs |  11 ++
 .../tests/typecheck/should_compile/T14363a.hs      |   8 ++
 testsuite/tests/typecheck/should_compile/all.T     |   2 +
 8 files changed, 207 insertions(+), 124 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 3acd6164fea6d4d5d87521a291455a18c9c9a8ee


More information about the ghc-commits mailing list