Skip to content

Trying to construct type-level Cantor's diagonal argument in GHC 8.2.2 causes ghc to panic

Summary

Trying to construct type-level Cantor's diagonal argument in GHC 8.2.2 causes ghc to panic.

However, the same code does not cause ghc panic in GHC 7.10.

Steps to reproduce

module Main where

data T = MakeT (T -> Bool)

runT :: T -> T -> Bool
runT (MakeT t) = t

paradox :: T -> Bool
paradox (MakeT t) = not $ t (MakeT t)

inParadox :: Bool
inParadox = paradox (MakeT paradox)

main = putStr "Hello, World!"

Running this results in

ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.2 for x86_64-unknown-linux):
	Simplifier ticks exhausted
  When trying UnfoldingDone paradox
  To increase the limit, use -fsimpl-tick-factor=N (default 100)
  If you need to do this, let GHC HQ know, and what factor you needed
  To see detailed counts use -ddump-simpl-stats
  Total ticks: 49481
  Call stack:
      CallStack (from HasCallStack):
        prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
        callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
        pprPanic, called at compiler/simplCore/SimplMonad.hs:199:31 in ghc:SimplMonad

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Expected behavior

ghc should not panic, since the result is not used.

Environment

  • GHC version used: 8.2.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information