[commit: ghc] master: Fix two obscure bugs in rule matching (3446cee)

git at git.haskell.org git at git.haskell.org
Thu Mar 22 08:25:19 UTC 2018


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

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

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

commit 3446cee05e08d78033e141fa46d4de6929542cbb
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Mar 21 17:25:23 2018 +0000

    Fix two obscure bugs in rule matching
    
    This patch fixes Trac #14777, a compiler crash.
    
    There were actually two bugs.
    
    1. In Rules.matchN, I was (consciously) not rename the template binders
       of the rule. Sadly, in rare cases an accidental coincidence of
       uniques could mean that a term variable was mapped to a type
       variable, utterly bogusly.  See "Historical note" in
       Note [Cloning the template binders] in Rules.
    
       This was hard to find, but easy to fix.
    
    2. The fix to (1) showed up a bug in Unify.hs.  The test in
       Unify.tvBindFlag was previously using the domain of the RnEnv2
       to detect locally-bound variables (e.g. when unifying under
       a forall).  That's fine when teh RnEnv2 starts empty, as it
       does in most entry points.  But the tcMatchTyKisX entry point,
       used from the rule matcher, passes in a non-empty RnEnv2 (by
       design).  Now the domain of the RnEnv doesn't idenfity those
       locally-bound variables any more :-(.
    
       Solution: extend UmEnv with a new field um_skols, to capture
       the skolems directly.  Simple, easy, works.


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

3446cee05e08d78033e141fa46d4de6929542cbb
 compiler/specialise/Rules.hs | 153 +++++++++++++++++++++++++------------------
 compiler/types/Unify.hs      | 121 ++++++++++++++++++----------------
 2 files changed, 154 insertions(+), 120 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 3446cee05e08d78033e141fa46d4de6929542cbb


More information about the ghc-commits mailing list