Opened 3 years ago

Closed 3 years ago

#12242 closed bug (fixed)

panic with complicated type/kind/class expressions

Reported by: Ashley Yakeley Owned by: simonpj
Priority: normal Milestone: 8.0.2
Component: Compiler Version: 8.0.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I tried to simplify this as much as I could, but I couldn't boil it down further than this:

-- ghc -O -ddump-hi -ddump-to-file Bug.hs
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
module Bug where
{
    import Data.Kind;

    data HetEq (a :: ka) (b :: kb) where
    {
        ReflH :: forall (k :: *) (t :: k). HetEq t t;
    };

    data Rep :: forall (k :: *). k -> * where
    {
        SimpleRep :: forall (k :: *) (a :: k). Rep a;
        ApplyRep :: forall (k1 :: *) (k2 :: *) (p :: k1 -> k2) (a :: k1). Rep p -> Rep a -> Rep (p a);
    };

    class TestHetEquality (w :: forall k. k -> *) where
    {
        testHetEquality :: forall (ka :: *) (a :: ka) (kb :: *) (b :: kb). w a -> w b -> Maybe (HetEq a b);
    };

    instance TestHetEquality Rep where
    {
        testHetEquality (ApplyRep tfa ta) (ApplyRep tfb tb) = do
        {
            ReflH <- testHetEquality tfa tfb;
            ReflH <- testHetEquality ta tb;
            return ReflH;
        };
        testHetEquality _ _ = Nothing;
    };

    bug :: forall (a :: *). Rep (Maybe a) -> Maybe (Rep a);
    bug (ApplyRep tf ta) = case testHetEquality tf SimpleRep of
    {
        Just ReflH  -> Just ta;
        Nothing -> Nothing;
    };
    bug _ = Nothing;
}

You'll need -O and -ddump-hi to trigger it.

$ stack exec -- ghc -O -ddump-hi -ddump-to-file Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for x86_64-unknown-linux):
	pprIfaceCo

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

Change History (6)

comment:1 Changed 3 years ago by Ashley Yakeley

Using resolver: nightly-2016-06-27 in my stack.yaml.

comment:2 Changed 3 years ago by simonpj

Owner: set to simonpj

Stupid inexhaustive case in pretty printing for IfaceCo. I'll fix.

comment:3 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In 24194a6a/ghc:

Fix pretty-printer for IfaceCo

As Trac #12242 showed, there was a missing case in
the pretty printer for IfaceCo. I've refactored it
so that the pattern-match ovelap checker will spot
it next time.

comment:4 Changed 3 years ago by simonpj

Status: newmerge

Pls merge. I didn't think it was worth a regression test

comment:5 Changed 3 years ago by Ben Gamari <ben@…>

In ba9dd63a/ghc:

Fix pretty-printer for IfaceCo

As Trac #12242 showed, there was a missing case in
the pretty printer for IfaceCo. I've refactored it
so that the pattern-match ovelap checker will spot
it next time.

(cherry picked from commit 24194a6aed950ed4c3733e3c582abf8a15d98ffd)

comment:6 Changed 3 years ago by bgamari

Milestone: 8.0.2
Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.