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

GHC ghc-devs at haskell.org
Thu Aug 24 22:59:37 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.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * cc: RyanGlScott (added)
 * version:  8.3 => 8.0.1


Old description:

> {{{#!hs
> {-# 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
>
> >
> }}}

New description:

 {{{#!hs
 {-# Language RankNTypes, 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

 >
 }}}

--

Comment:

 Interesting! This appears to be an old bug, since it happens all the way
 back in GHC 8.0.1 (that's as far back as I can go, since
 `TypeApplications` didn't exist before then).

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


More information about the ghc-tickets mailing list