Opened 3 years ago

Last modified 16 months ago

#12451 new bug

TemplateHaskell and Data.Typeable - tcIfaceGlobal (local): not found

Reported by: mkloczko Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 8.0.1
Keywords: TemplateHaskell, Typeable Cc:
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: #12452 Differential Rev(s):
Wiki Page:


The following code produces an ghc panic error:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ScopedTypeVariables #-}

module TH where

import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import Data.Typeable

usingType :: forall a. Typeable a => a -> Q [Dec]
usingType _ = do
    -- Try to get anything using typeRep.
    let name = (tyConName $ typeRepTyCon $ typeRep (Proxy :: Proxy a)) `seq` "The name!"
    -- theF = "The name!"
    return [FunD (mkName "theF") [Clause [] (NormalB $ LitE $ StringL name )  []]]
{-# LANGUAGE TemplateHaskell #-}

module Main where
import TH 

data A = A Int

-- Changing the argument to (A 3) does not help.
$(usingType (undefined :: A))

main = putStrLn $ theF

The error:

ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
	tcIfaceGlobal (local): not found:
  [r5m0 :-> Type constructor ‘A’, r5m3 :-> Data constructor ‘A’,
   r5m9 :-> Identifier ‘A’]

Change History (3)

comment:1 Changed 3 years ago by goldfire

Component: CompilerTemplate Haskell

Thanks for reporting!

comment:2 Changed 16 months ago by RyanGlScott

In GHC 8.4 and HEAD, the error message has changed:

$ /opt/ghc/head/bin/ghc -fforce-recomp Main.hs
[1 of 2] Compiling TH               ( TH.hs, TH.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )
GHC error in desugarer lookup in Main:
  attempting to use module ‘main:Main’ (Main.hs) which is not loaded

comment:3 Changed 16 months ago by RyanGlScott

Note: See TracTickets for help on using tickets.