[commit: ghc] ghc-8.0: Fix a number of subtle solver bugs (9f466c8)

git at git.haskell.org git at git.haskell.org
Mon Jan 18 10:55:51 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/9f466c8841c7ddda84951c9e3470540d25d0bfdb/ghc

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

commit 9f466c8841c7ddda84951c9e3470540d25d0bfdb
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Sat Jan 16 00:37:15 2016 +0000

    Fix a number of subtle solver bugs
    
    As a result of some other unrelated changes I found that
    IndTypesPerf was failing, and opened Trac #11408.  There's
    a test in indexed-types/should-compile/T11408.
    
    The bug was that a type like
     forall t. (MT (UL t) (UR t) ~ t) => UL t -> UR t -> Int
    is in fact unambiguous, but it's a bit subtle to prove
    that it is unambiguous.
    
    In investigating, Dimitrios and I found several subtle
    bugs in the constraint solver, fixed by this patch
    
    * canRewrite was missing a Derived/Derived case.  This was
      lost by accident in Richard's big kind-equality patch.
    
    * Interact.interactTyVarEq would discard [D] a ~ ty if there
      was a [W] a ~ ty in the inert set.  But that is wrong because
      the former can rewrite things that the latter cannot.
      Fix: a new function eqCanDischarge
    
    * In TcSMonad.addInertEq, the process was outright wrong for
      a Given/Wanted in the (GWModel) case.  We were adding a new
      Derived without kicking out things that it could rewrite.
      Now the code is simpler (no special GWModel case), and works
      correctly.
    
    * The special case in kickOutRewritable for [W] fsk ~ ty,
      turns out not to be needed.  (We emit a [D] fsk ~ ty which
      will do the job.
    
    I improved comments and documentation, esp in TcSMonad.
    
    (cherry picked from commit 9308c736d43b92bf8634babf565048e66e071bd8)


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

9f466c8841c7ddda84951c9e3470540d25d0bfdb
 compiler/typecheck/TcCanonical.hs                  |   4 +-
 compiler/typecheck/TcFlatten.hs                    |   4 +-
 compiler/typecheck/TcInteract.hs                   |  49 ++--
 compiler/typecheck/TcRnTypes.hs                    |  99 ++++---
 compiler/typecheck/TcSMonad.hs                     | 290 ++++++++++++---------
 .../should_compile/IndTypesPerfMerge.hs            |  44 ++++
 testsuite/tests/indexed-types/should_compile/all.T |   1 +
 .../tests/typecheck/should_fail/tcfail201.stderr   |   4 +-
 8 files changed, 304 insertions(+), 191 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 9f466c8841c7ddda84951c9e3470540d25d0bfdb


More information about the ghc-commits mailing list