[GHC] #8987: TH: panic in reportWarning when the message throws an exception

GHC ghc-devs at haskell.org
Fri Apr 11 15:28:52 UTC 2014


#8987: TH: panic in reportWarning when the message throws an exception
-----------------------------------+---------------------------------------
       Reporter:  Yuras            |             Owner:
           Type:  bug              |            Status:  new
       Priority:  normal           |         Milestone:
      Component:  Compiler         |           Version:  7.8.1
       Keywords:                   |  Operating System:  Unknown/Multiple
   Architecture:                   |   Type of failure:  Compile-time crash
  Unknown/Multiple                 |         Test Case:
     Difficulty:  Unknown          |          Blocking:
     Blocked By:                   |
Related Tickets:                   |
-----------------------------------+---------------------------------------
 `reportWarning` and `reportError` doesn't force it's argument, so `ghc`
 panics when printing the message.

 To reproduce:

 {{{#!haskell
 test :: Q [Dec]
 test = do
   reportWarning undefined
   return []
 }}}

 Output:
 {{{
 main.hs:5:3: Warning:ghc: panic! (the 'impossible' happened)
   (GHC version 7.8.1 for x86_64-unknown-linux):
         Prelude.undefined

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

 The fix could be:
 {{{
 --- a/compiler/typecheck/TcSplice.lhs
 +++ b/compiler/typecheck/TcSplice.lhs
 @@ -875,8 +875,8 @@ instance TH.Quasi (IOEnv (Env TcGblEnv TcLclEnv))
 where
                    ; let i = getKey u
                    ; return (TH.mkNameU s i) }

 -  qReport True msg  = addErr  (text msg)
 -  qReport False msg = addWarn (text msg)
 +  qReport True !msg  = addErr  (text msg)
 +  qReport False !msg = addWarn (text msg)

    qLocation = do { m <- getModule
                   ; l <- getSrcSpanM
 }}}

 But possibly it should `deepseq` the argument?

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


More information about the ghc-tickets mailing list