FYI panic "flatten_args wandered into deeper water than usual"

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: http://www.haskell.org/ghc/reportabug
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

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). Richard
On Jan 5, 2019, at 11:46 PM, Nicolas Frisby
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: http://www.haskell.org/ghc/reportabug http://www.haskell.org/ghc/reportabug
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (2)
-
Nicolas Frisby
-
Richard Eisenberg