panic when using a function defined in terms of `error`
The error message I got from GHC was:
<no location info>: error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.2.2 for x86_64-unknown-linux):
idInfo
t_XG0J
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Var.hs:526:34 in ghc:Var
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
How was it triggerred (in short):
There's function definition, f x = undefined
. If I change it to f x = __impossible "Oops!"
, ghc crashes. If I change it to f x = error "Oops!"
, it's OK. The definition of __impossible
is simply __impossible s = error $ s ++ "some text"
.
The code can be found here: https://github.com/NICTA/cogent/blob/9420861128a8c445138aa6a48c62140d8c5f72eb/cogent/src/Cogent/Desugar.hs#L482 and https://github.com/NICTA/cogent/blob/9420861128a8c445138aa6a48c62140d8c5f72eb/cogent/src/Cogent/Compiler.hs#L30
It seems that this bug is not limited to 8.2.2; it also happened in 8.2.1.
I'm happy to provide more information, if someone can advice me what is needed. I'll also try to shrink it to a small test case.