FYI panic "flatten_args wandered into deeper water than usual"

Richard Eisenberg rae at
Mon Jan 7 14:58:40 UTC 2019

I suspect that you spent a good deal of time in search of this knowledge.

Is there something in this code that could have helped you do this faster? Unfortunately, the water in flatten_args is indeed deep, and I don't think there's any way to fix that. I've considered writing a peer-reviewed paper just to explain that one function, but decided that no one would care enough to read it (though implementors of other dependently typed languages likely have had to do similar).


> On Jan 5, 2019, at 11:46 PM, Nicolas Frisby <nicolas.frisby at> wrote:
> While developing a typechecker plugin, I experienced this error message.
> > ghc: panic! (the 'impossible' happened)
> >   (GHC version 8.6.2 for x86_64-unknown-linux):
> > 	flatten_args wandered into deeper water than usual
> >   Call stack:
> >       CallStack (from HasCallStack):
> >         callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
> >         pprPanic, called at compiler/typecheck/TcFlatten.hs:1331:24 in ghc:TcFlatten
> > 
> > Please report this as a GHC bug: <>
> I'm sending this email just in case a dev is curious how this panic arises or if another plugin developer sees the same thing -- the error message is not very informative, and the corresponding GHC source code is a bit obtuse.
> Based on the relevant GHC source code and my recent plugin edits, I was able to guess correctly that this was due to me generating an extra sort argument to a promoted datacon. Specifically, I was incorrectly using
> > mkTyConApp (promoteDataCon _) [typeKind k,k,...]
> instead of just
> > mkTyConApp (promoteDataCon _) [k,...]
> Thanks! HTH. -Nick
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list