summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-01-19 13:59:18 -0500
committerBen Gamari <ben@smart-cactus.org>2019-01-27 08:32:12 -0500
commit0d9f105ba423af4f2ca215a18d04d4c8e2c372a8 (patch)
treebfea743530b22249f2115aac0869abcadac0bcce
parent372b5d1b4543334d9b446dc897227b838e40cf4e (diff)
downloadhaskell-0d9f105ba423af4f2ca215a18d04d4c8e2c372a8.tar.gz
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. This was the cause of #16104. The solution is simple: use the nicely packaged `lookupOrigIO` instead.
-rw-r--r--compiler/main/GhcPlugins.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/main/GhcPlugins.hs b/compiler/main/GhcPlugins.hs
index 3e0facf97b..56492377d8 100644
--- a/compiler/main/GhcPlugins.hs
+++ b/compiler/main/GhcPlugins.hs
@@ -87,7 +87,7 @@ import Unique ( Unique, Uniquable(..) )
import FastString
import Data.Maybe
-import NameCache (lookupOrigNameCache)
+import IfaceEnv ( lookupOrigIO )
import GhcPrelude
import MonadUtils ( mapMaybeM )
import Convert ( thRdrNameGuesses )
@@ -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