[GHC] #16104: Plugin name lookup behavior change from GHC 8.4 series

GHC ghc-devs at haskell.org
Tue Jan 15 16:46:39 UTC 2019


#16104: Plugin name lookup behavior change from GHC 8.4 series
-------------------------------------+-------------------------------------
        Reporter:  lerkok            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 In GHC 8.4 we have
 {{{
 thNameToGhcName th_name = do
     hsc_env <- getHscEnv
     liftIO $ initTcForLookup hsc_env (lookupThName_maybe th_name)
 }}}

 `lookupThName` ends up calling `lookupGlobalOccRn_maybe`; and (since I
 think we have an `Orig` at this point) thence `lookupExactOrOrig`, and
 thence `IfaceEnv.lookupOrig`.  The latter
 * Looks up in the original-name cache
 * If the lookup fails, it makes a fresh external `Name`, updates the orig-
 name cache, and returns the `Name`.

 But in 8.6 we have
 {{{
 thNameToGhcName th_name
   =  do { names <- mapMaybeM lookup (thRdrNameGuesses th_name)
           -- Pick the first that works
           -- E.g. reify (mkName "A") will pick the class A in preference
           -- to the data constructor A
         ; return (listToMaybe names) }
   where
     lookup rdr_name
       | Just n <- isExact_maybe rdr_name   -- This happens in derived code
       = return $ if isExternalName n then Just n else Nothing
       | Just (rdr_mod, rdr_occ) <- isOrig_maybe rdr_name
       = do { cache <- getOrigNameCache
            ; return $ lookupOrigNameCache cache rdr_mod rdr_occ }
       | otherwise = return Nothing
 }}}
 See: it looks up in the orig-name cache, but doesn't extend it on failure.

 That's what's going wrong.  We just need to do what `lookupOrig` does.

 In HEAD some more refactoring has happened, which makes it easier.  We
 want `thNameToGhcName` to call something very like
 `IfaceEnv.lookupOrigIO`.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16104#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list