#6114: ghc: panic! occurred with use of isInstance, newName and a type splice
--------------------------------+-------------------------------------------
 Reporter:  davidmiani          |          Owner:                  
     Type:  bug                 |         Status:  new             
 Priority:  normal              |      Component:  Template Haskell
  Version:  7.4.1               |       Keywords:                  
       Os:  MacOS X             |   Architecture:  x86_64 (amd64)  
  Failure:  Compile-time crash  |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6114>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to