id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
5971,"Referencing a newName in a VarE without definition triggers ""the impossible happened""",josh,,"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"")
}}}",bug,closed,normal,,Compiler,7.4.1,fixed,,,Unknown/Multiple,Unknown/Multiple,Compile-time crash,Unknown,th/T5971,,,
