[commit: ghc] master: Use tcExtendGlobalValEnv for default methods (990ce8c)

git at git.haskell.org git at git.haskell.org
Fri May 6 07:30:39 UTC 2016


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

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

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

commit 990ce8c95bf99e79c728f90aa68bff101867c073
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri May 6 08:21:33 2016 +0100

    Use tcExtendGlobalValEnv for default methods
    
    We add the default method Ids to the global type envt in
    tcAddImplicits; and then again in tcInstDcls2 (for reasons
    explained there).  But for some reason in the latter case
    we added them to the /local/ type envt, via tcExtendLetEnv.
    
    This patch just uses tcExtendGlobalValEnv consistently
    for both.
    
    (I found this when reviewing slightly-awkward code from Facundo's
    static-form error-message patch; turned out that the awkwardness
    came back to this inconsistency in the handling of default
    methods.)


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

990ce8c95bf99e79c728f90aa68bff101867c073
 compiler/typecheck/TcInstDcls.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index 483d322..59ddaee 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -731,8 +731,9 @@ tcInstDecls2 tycl_decls inst_decls
           -- (b) instance declarations
         ; let dm_ids = collectHsBindsBinders dm_binds
               -- Add the default method Ids (again)
+              -- (they were arready added in TcTyDecls.tcAddImplicits)
               -- See Note [Default methods and instances]
-        ; inst_binds_s <- tcExtendLetEnv TopLevel TopLevel dm_ids $
+        ; inst_binds_s <- tcExtendGlobalValEnv dm_ids $
                           mapM tcInstDecl2 inst_decls
 
           -- Done
@@ -742,7 +743,7 @@ tcInstDecls2 tycl_decls inst_decls
 See Note [Default methods and instances]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The default method Ids are already in the type environment (see Note
-[Default method Ids and Template Haskell] in TcTyClsDcls), BUT they
+[Default method Ids and Template Haskell] in TcTyDcls), BUT they
 don't have their InlinePragmas yet.  Usually that would not matter,
 because the simplifier propagates information from binding site to
 use.  But, unusually, when compiling instance decls we *copy* the



More information about the ghc-commits mailing list