#5971: Referencing a newName in a VarE without definition triggers "the 
impossible
happened"
--------------------------------+-------------------------------------------
 Reporter:  josh                |          Owner:                  
     Type:  bug                 |         Status:  new             
 Priority:  normal              |      Component:  Compiler        
  Version:  7.4.1               |       Keywords:                  
       Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
  Failure:  Compile-time crash  |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------
 Test case:

 {{{
 {-# LANGUAGE TemplateHaskell #-}
 import Language.Haskell.TH

 _ = $(newName "x" >>= varE)
 }}}

 Result:

 {{{
 $ runghc test.hs
 ghc: panic! (the 'impossible' happened)
   (GHC version 7.4.1 for x86_64-unknown-linux):
         nameModule x_aSd{v}

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
 }}}

 Similar results from ghci:

 {{{
 $ ghci
 GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Prelude> :set -XTemplateHaskell
 Prelude> import Language.Haskell.TH
 Prelude Language.Haskell.TH> $(newName "x" >>= varE)
 Loading package array-0.4.0.0 ... linking ... done.
 Loading package deepseq-1.3.0.0 ... linking ... done.
 Loading package containers-0.4.2.1 ... linking ... done.
 Loading package pretty-1.1.1.0 ... linking ... done.
 Loading package template-haskell ... linking ... done.
 ghc: panic! (the 'impossible' happened)
   (GHC version 7.4.1 for x86_64-unknown-linux):
         nameModule x_aSm{v}

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
 }}}

 Note that referencing an undefined name via mkName generates a reasonable
 error message rather than "the impossible happened":

 {{{
 Prelude Language.Haskell.TH> $(varE $ mkName "x")

 <interactive>:6:3:
     Not in scope: `x'
     In the result of the splice:
       $(varE $ mkName "x")
     To see what the splice expanded to, use -ddump-splices
     In the expression: $(varE $ mkName "x")
     In an equation for `it': it = $(varE $ mkName "x")
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5971>
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