[commit: ghc] master: Refactor the GlobalRdrEnv, fixing #7672 (9b73cb1)

git at git.haskell.org git at git.haskell.org
Tue Jun 2 09:34:17 UTC 2015


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

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

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

commit 9b73cb16485f331d9dc1f37826c6d503e24a5b0b
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Jun 2 00:02:03 2015 +0100

    Refactor the GlobalRdrEnv, fixing #7672
    
    This patch started innocently enough, by deleting a single
    call from rnImportDecl, namely
    
        let gbl_env = mkGlobalRdrEnv (filterOut from_this_mod gres)
    
    The 'filterOut' makes no sense, and was the cause of #7672.
    
    But that little loose end led to into a twisty maze of little
    passages, all alike, which has taken me an unreasonably long
    time to straighten out. Happily, I think the result is really
    much better.
    
    In particular:
    
     * INVARIANT 1 of the GlobalRdrEnv type was simply not true:
       we had multiple GlobalRdrElts in a list with the same
       gre_name field. This kludgily implmented one form of
       shadowing.
    
     * Meanwhile, extendGlobalRdrEnvRn implemented a second form of
       shadowing, by deleting stuff from the GlobalRdrEnv.
    
     * In turn, much of this shadowing stuff depended on the Names of
       the Ids bound in the GHCi InteractiveContext being Internal
       names, even though the TyCons and suchlike all had External
       Names. Very confusing.
    
    So I have made the following changes
    
     * I re-established INVARIANT 1 of GlobalRdrEnv.  As a result
       some strange code in RdrName.pickGREs goes away.
    
     * RnNames.extendGlobalRdrEnvRn now makes one call to deal with
       shadowing, where necessary, and another to extend the
       environment.  It deals separately with duplicate bindings.
    
       The very complicated RdrName.extendGlobalRdrEnv becomes much
       simpler; we need to export the shadowing function, now called
       RdrName.shadowNames; and we can nuke
       RdrName.findLocalDupsRdrEnv altogether.
    
       RdrName Note [GlobalRdrEnv shadowing] summarises the shadowing
       story
    
     * The Names of the Ids bound in the GHCi interactive context are
       now all External.  See Note [Interactively-bound Ids in GHCi]
       in HscTypes.
    
     * Names for Ids created by the debugger are now made by
       IfaceEnv.newInteractiveBinder.  This fixes a lurking bug which
       was that the debugger was using mkNewUniqueSupply 'I' to make
       uniques, which does NOT guarantee a fresh supply of uniques on
       successive calls.
    
     * Note [Template Haskell ambiguity] in RnEnv shows that one TH-related
       error is reported lazily (on occurrences) when it might be better
       reported when extending the environment.  In some (but not all) cases
       this was done before; but now it's uniformly at occurrences.  In
       some ways it'd be better to report when extending the environment,
       but it's a tiresome test and the error is rare, so I'm leaving it
       at the lookup site for now, with the above Note.
    
     * A small thing: RnNames.greAvail becomes RdrName.availFromGRE, where
       it joins the dual RdrName.gresFromAvail.


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

9b73cb16485f331d9dc1f37826c6d503e24a5b0b
 compiler/basicTypes/RdrName.hs                     | 206 ++++++++++-----------
 compiler/ghci/Debugger.hs                          |  29 ++-
 compiler/iface/IfaceEnv.hs                         |  62 ++++---
 compiler/main/HscTypes.hs                          |  44 +++--
 compiler/main/InteractiveEval.hs                   |  71 ++++---
 compiler/rename/RnEnv.hs                           | 144 ++++++++------
 compiler/rename/RnNames.hs                         | 118 ++++++------
 compiler/typecheck/TcEnv.hs                        |  69 +------
 compiler/typecheck/TcRnDriver.hs                   | 100 +++++++---
 .../tests/ghci.debugger/scripts/break027.stdout    |   8 +-
 testsuite/tests/ghci/scripts/T10248.stderr         |  10 +-
 testsuite/tests/ghci/scripts/T5564.stderr          |   7 +-
 testsuite/tests/module/mod110.stderr               |   6 +-
 testsuite/tests/module/mod151.stderr               |   6 +-
 testsuite/tests/module/mod152.stderr               |  13 +-
 testsuite/tests/module/mod153.stderr               |   6 +-
 testsuite/tests/rename/should_compile/T1972.stderr |   8 +-
 testsuite/tests/rename/should_fail/T5533.stderr    |   4 +-
 testsuite/tests/rename/should_fail/T7906.stderr    |   4 +-
 testsuite/tests/rename/should_fail/rn_dup.stderr   |  20 +-
 .../tests/rename/should_fail/rnfail044.stderr      |   6 +-
 testsuite/tests/th/T7241.stderr                    |  10 +-
 testsuite/tests/th/T8932.stderr                    |   8 +-
 .../tests/typecheck/should_fail/tcfail037.stderr   |   7 +-
 24 files changed, 489 insertions(+), 477 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 9b73cb16485f331d9dc1f37826c6d503e24a5b0b


More information about the ghc-commits mailing list