Skip to content

Match on GADT triggers -dstg-lint panic when -fcatch-bottoms is enabled

GHC panics when compiling the following program with -dstg-lint -fcatch-bottoms:

{-# LANGUAGE GADTs #-}
module M where
data T a where
  A :: T Int
  B :: T Bool

f :: T Int -> ()
f A = ()
$ ghc -dstg-lint -fcatch-bottoms M.hs
[1 of 1] Compiling M                ( M.hs, M.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.0.20191210:
	assertConsistentCafInfo
  f :: T Int -> ()
  [GblId, Arity=1, Caf=NoCafRefs, Unf=OtherCon []] =
      \r [ds_sHF]
          case ds_sHF of {
            __DEFAULT -> runtimeError "Bottoming expression returned"#;
            A co_aAp -> () [];
          };
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
        pprPanic, called at compiler/stgSyn/CoreToStg.hs:309:39 in ghc:CoreToStg

I have reproduced this on both 8.8.1 and 8.10.1-alpha2. The error occurs regardless of optimization flags.

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