[commit: ghc] wip/T16104: GhcPlugins: Fix lookup of TH names (68be64e)

git at git.haskell.org git at git.haskell.org
Sat Jan 19 19:04:19 UTC 2019


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

On branch  : wip/T16104
Link       : http://ghc.haskell.org/trac/ghc/changeset/68be64ee57d522e6f5b2df027cdc0c729126787b/ghc

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

commit 68be64ee57d522e6f5b2df027cdc0c729126787b
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Jan 19 13:59:18 2019 -0500

    GhcPlugins: Fix lookup of TH names
    
    Previously `thNameToGhcName` was calling `lookupOrigNameCache` directly, which
    failed to handle the case that the name wasn't already in the name cache. This
    happens, for instance, when the name was in scope in a plugin being used during
    compilation but not in scope in the module being compiled. In this case we the
    interface file containing the name won't be loaded and `lookupOrigNameCache`
    fails.
    
    The solution is simple: use the nicely packaged `lookupOrigIO` instead.


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

68be64ee57d522e6f5b2df027cdc0c729126787b
 compiler/main/GhcPlugins.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler/main/GhcPlugins.hs b/compiler/main/GhcPlugins.hs
index 3e0facf..993b13b 100644
--- a/compiler/main/GhcPlugins.hs
+++ b/compiler/main/GhcPlugins.hs
@@ -127,6 +127,6 @@ thNameToGhcName th_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 }
+      = do { hsc_env <- getHscEnv
+           ; Just <$> liftIO (lookupOrigIO hsc_env rdr_mod rdr_occ) }
       | otherwise = return Nothing



More information about the ghc-commits mailing list