Opened 10 days ago

Closed 10 days ago

Last modified 10 days ago

#15709 closed bug (duplicate)

GHC panic using TypeInType with minimal source code

Reported by: jnape Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.4.3
Keywords: TypeInType Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The following source code causes GHC 8.4.3 on 64bit Linux to panic:

{-# LANGUAGE TypeInType #-}

module Lib where

import Data.Kind

class Contravariant f where
    contramap :: (a -> b) -> f b -> f a

dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) => (z -> a) -> (b -> c) -> p a b -> p z c
dimap f g = contramap f . fmap g

I have no idea if it should compile or not, but it shouldn't do this:

ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.3 for x86_64-unknown-linux):
	piResultTy
  k_a34u[tau:1]
  *
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:947:35 in ghc:Type

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

Change History (2)

comment:1 Changed 10 days ago by simonpj

Resolution: duplicate
Status: newclosed

Happily, I think this is probably fixed. (Search for the many tickets with piResultTy in them.

GHC 8.6 fails with

T15709.hs:10:25: error:
    • Expecting one more argument to ‘(p :: * -> b -> p * b)’
      Expected kind ‘* -> *’,
        but ‘(p :: * -> b -> p * b)’ has kind ‘* -> b -> p * b’
    • In the first argument of ‘Contravariant’, namely
        ‘(p :: * -> b -> p * b)’
      In the type signature:
        dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) =>
                 (z -> a) -> (b -> c) -> p a b -> p z c
   |
10 | dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) => (z -> a)  -> (b -> c) -> p a b -> p z c
   |                         ^^^^^^^^^^^^^^^^^^^^^^

T15709.hs:10:26: error:
    • Expected kind ‘* -> b -> p * b’, but ‘p’ has kind ‘* -> * -> *’
    • In the first argument of ‘Contravariant’, namely
        ‘(p :: * -> b -> p * b)’
      In the type signature:
        dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) =>
                 (z -> a) -> (b -> c) -> p a b -> p z c
   |
10 | dimap :: (Contravariant (p :: * -> b -> p * b), Functor (p a)) => (z -> a)  -> (b -> c) -> p a b -> p z c
   |                          ^

comment:2 Changed 10 days ago by jnape

Wonderful! Sorry for the duplicate.

Note: See TracTickets for help on using tickets.