Skip to content

Some cocktail of features causes GHC panic

{-# Language RankNTypes, DerivingStrategies, TypeApplications,
    ScopedTypeVariables, GADTs, PolyKinds #-}

module T14154 where

newtype Ran g h a
  = MkRan (forall b. (a -> g b) -> h b)

newtype Swap p f g a where
  MkSwap :: p g f a -> Swap p f g a

ireturn :: forall m i a. a -> m i i a
ireturn = undefined

xs = case ireturn @(Swap Ran) 'a' of 
       MkSwap (MkRan f) -> f print
$ ghci -ignore-dot-ghci /tmp/bug.hs
GHCi, version 8.3.20170605: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.3.20170605 for x86_64-unknown-linux):
	piResultTy
  k0_a1Ki[tau:2]
  b0_a1Kt[tau:2]
  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/types/Type.hs:949:35 in ghc:Type

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

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