Skip to content

GHC API panic (evaluated the place holder for a PostTcType)

The same code that works for GHC 7.10.2 blows up on GHC 7.8.4, with errors like

    test/ArgonSpec.hs:104: (best-effort)
      6) Argon.analyze accounts for && operator
           uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened)
             (GHC version 7.8.4 for x86_64-unknown-linux):
           	fixity
           
           Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
           )
    
      test/ArgonSpec.hs:106: (best-effort)
      7) Argon.analyze counts everything in a real example
           uncaught exception: GhcException (argon-test: panic! (the 'impossible' happened)
             (GHC version 7.8.4 for x86_64-unknown-linux):
           	Evaluated the place holder for a PostTcType
           
           Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
           )

The responsible module is https://github.com/rubik/argon/blob/ghc-7.8/src/Argon/Visitor.hs and in particular (I think):

visitExp :: Exp -> Int
visitExp (GHC.HsIf {}) = 1
visitExp (GHC.HsMultiIf _ alts) = length alts - 1
visitExp (GHC.HsLamCase _ alts) = length (GHC.mg_alts alts) - 1
visitExp (GHC.HsCase _ alts)    = length (GHC.mg_alts alts) - 1
visitExp _ = 0

visitOp :: Exp -> Int
visitOp (GHC.OpApp _ (GHC.L _ (GHC.HsVar op)) _ _) =
    case getName op of
      "||" -> 1
      "&&" -> 1
      _    -> 0
visitOp _ = 0

somehow, even if I use wildcards, the first arguments of the type constructors gets evaluated and since it's undefined GHC crashes. What am I supposed to do? The documentation does not say anything on the matter.

Edited by rubik
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information