[GHC] #14154: Some cocktail of features causes GHC panic

GHC ghc-devs at haskell.org
Thu Aug 24 19:41:01 UTC 2017


#14154: Some cocktail of features causes GHC panic
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 {{{
 {-# Language RankNTypes, DerivingStrategies, TypeApplications,
 ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs,
 PolyKinds #-}

 import Data.Coerce

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

 newtype Swap p f g a where
   Swap :: p g f a -> Swap p f g a
   deriving newtype
     Show

 class IxPointed m where
   ireturn :: a -> m i i a

 instance IxPointed f => IxPointed (Swap f) where
   ireturn :: forall a i. a -> Swap f i i a
   ireturn = coerce (ireturn @f @a @i)

 instance IxPointed Ran where
   ireturn :: a -> Ran i i a
   ireturn a = Ran (\k -> k a)

 xs =
   case ireturn @(Swap Main.Ran) 'a' of
     Swap (Ran 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

 >
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14154>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list