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-02-10 19:56:41 -0500
commit5abfd982f55287b24fd71a5d60a2e3d0e361e47e (patch)
tree6f3d717efd476e21949050c7716a17a6be8442d7
parent8c2dbc161572b59498a9d7abe444e65973069ef7 (diff)
downloadhaskell-5abfd982f55287b24fd71a5d60a2e3d0e361e47e.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. (cherry picked from commit 0d9f105ba423af4f2ca215a18d04d4c8e2c372a8)
-rw-r--r--compiler/simplCore/CoreMonad.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/simplCore/CoreMonad.hs b/compiler/simplCore/CoreMonad.hs
index 912ff9949c..683fb0434d 100644
--- a/compiler/simplCore/CoreMonad.hs
+++ b/compiler/simplCore/CoreMonad.hs
@@ -67,6 +67,7 @@ import Annotations
import IOEnv hiding ( liftIO, failM, failWithM )
import qualified IOEnv ( liftIO )
+import IfaceEnv ( lookupOrigIO )
import TcEnv ( lookupGlobal )
import Var
import Outputable
@@ -821,6 +822,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