GHC fails to locate TH NameG that refers to a record selector
The following pair of modules trigger a bug in GHC HEAD (but not in 9.6.1):
module A where
newtype T = T { getT :: () }
{-# LANGUAGE TemplateHaskell #-}
module B where
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
import A ()
getT = $(varE (mkNameG_v "main" "A" "getT"))
$ ghc A B
[1 of 2] Compiling A ( A.hs, A.o, A.dyn_o )
[2 of 2] Compiling B ( B.hs, B.o )
B.hs:6:9: error: [GHC-83249]
• Can't find interface-file declaration for variable A.getT
Probable cause: bug in .hi-boot file, or inconsistent .hi file
Use -ddump-if-trace to get an idea of which file caused the error
• In the untyped splice: $(varE (mkNameG_v "main" "A" "getT"))
|
6 | getT = $(varE (mkNameG_v "main" "A" "getT"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I discovered this issue when compiling the text-show
package using GHC HEAD, which depends on this working.