id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
6114,"ghc: panic! occurred with use of isInstance, newName and a type splice",davidmiani,,"Compiling the below code:


{{{
{-# LANGUAGE TemplateHaskell #-}
module Test where
import Language.Haskell.TH
import Control.Monad.Instances ()    

instanceVar = $(do
                 xName <- newName ""x""
                 instanceType <- [t| (Int -> $(varT xName)) |]
                 instanceOfFunctor <- isInstance ''Functor [instanceType]
                 stringE $ show instanceOfFunctor
               )
}}}

Results in the following error:



{{{
[1 of 1] Compiling Test             ( test.hs, interpreted )

test.hs:6:17:
    Exception when trying to run compile-time code:
      ghc: panic! (the 'impossible' happened)
  (GHC version 7.4.1 for x86_64-apple-darwin):
	nameModule x_a1ws{tv}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

      Code: do { xName <- newName ""x"";
                 instanceType <- [t| Int -> $(varT xName) |]
                                 pending [(splice, varT xName)];
                 instanceOfFunctor <- isInstance ''Functor [instanceType];
                 .... }
    In the expression:
      $(do { xName <- newName ""x"";
             instanceType <- [t| Int -> $(varT xName) |];
             instanceOfFunctor <- isInstance ''Functor [instanceType];
             .... })
    In an equation for `instanceVar':
        instanceVar
          = $(do { xName <- newName ""x"";
                   instanceType <- [t| Int -> $(varT xName) |];
                   .... })
Failed, modules loaded: none.
}}}




While the code is not correct (replacing the `instanceType` line with 

`instanceType <- [t| (->) Int |]` 

fixes the problem), a better error message would be desirable.
",bug,closed,normal,,Template Haskell,7.4.1,fixed,,,MacOS X,x86_64 (amd64),Compile-time crash,Unknown,th/T6114,,,
