<div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div>While developing a typechecker plugin, I experienced this error message.<br><br>> ghc: panic! (the 'impossible' happened)</div><div>>   (GHC version 8.6.2 for x86_64-unknown-linux):</div><div>> <span style="white-space:pre">      </span>flatten_args wandered into deeper water than usual</div><div>>   Call stack:</div><div>>       CallStack (from HasCallStack):</div><div>>         callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable</div><div>>         pprPanic, called at compiler/typecheck/TcFlatten.hs:1331:24 in ghc:TcFlatten</div><div>> </div><div>> Please report this as a GHC bug:  <a href="http://www.haskell.org/ghc/reportabug">http://www.haskell.org/ghc/reportabug</a></div></div><div><br></div><div>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.</div><div><br></div><div>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</div><div><br></div><div>> mkTyConApp (promoteDataCon _) [typeKind k,k,...]<br></div><div><br></div><div>instead of just</div><div><br></div><div>> mkTyConApp (promoteDataCon _) [k,...]</div><div><br></div><div>Thanks! HTH. -Nick</div></div></div></div>