[commit: ghc] master: Fix egregious duplication of vars in RnTypes (b9ac9e0)

git at git.haskell.org git at git.haskell.org
Tue Sep 5 11:22:10 UTC 2017


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

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

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

commit b9ac9e05b29c58efc93b78bf7fca43d61ead50c7
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Mon Sep 4 08:00:29 2017 -0400

    Fix egregious duplication of vars in RnTypes
    
    `RnTypes` contains a fairly intricate algorithm to extract
    the kind and type variables of an HsType. This algorithm carefully
    maintains the separation between type variables and kind variables
    so that the difference between `-XPolyKinds` and `-XTypeInType` can
    be respected.
    
    But after doing all this, `rmDupsInRdrTyVars` stupidly just
    concatenated the lists of type and kind variables at the end. If a
    variable were used as both a type and a kind, the algorithm would
    produce *both*! This led to all kinds of problems, including #13988.
    
    This is mostly Richard Eisenberg's patch. The only original
    contribution I made was adapting call sites of `rnImplicitBndrs` to
    work with the new definition of `rmDupsInRdrTyVars`. That is,
    `rnImplicitBndrs` checks for variables that are illegally used in
    both type and kind positions without using `-XTypeInType`, but in
    order to check this, one cannot have filtered duplicate variables out
    before passing them to `rnImplicitBndrs`. To accommodate for this, I
    needed to concoct variations on the existing `extract-` functions in
    `RnTypes` which do not remove duplicates, and use those near
    `rnImplicitBndrs` call sites.
    
    test case: ghci/scripts/T13988
    
    Test Plan: make test TEST=T13988
    
    Reviewers: goldfire, simonpj, austin, bgamari
    
    Reviewed By: goldfire, simonpj
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #13988
    
    Differential Revision: https://phabricator.haskell.org/D3902


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

b9ac9e05b29c58efc93b78bf7fca43d61ead50c7
 compiler/rename/RnTypes.hs                 | 131 ++++++++++++++++++++++-------
 testsuite/tests/ghci/scripts/T13988.hs     |   8 ++
 testsuite/tests/ghci/scripts/T13988.script |   2 +
 testsuite/tests/ghci/scripts/T13988.stdout |   1 +
 testsuite/tests/ghci/scripts/all.T         |   1 +
 5 files changed, 114 insertions(+), 29 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 b9ac9e05b29c58efc93b78bf7fca43d61ead50c7


More information about the ghc-commits mailing list