Opened 4 years ago

Closed 4 years ago

#8893 closed bug (fixed)

-XPolyKinds causes "*** Exception: Prelude.(!!): index too large"

Reported by: ghorn Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.8.1-rc2
Keywords: PolyKinds Cc: gregmainland@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: deriving/should_compile/T8893
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following program will compile fine:

{-# OPTIONS_GHC -Wall #-}
{-# Language DeriveFunctor #-}
--{-# Language PolyKinds #-}

module Bug where

data V a = V [a] deriving Functor

data C x a = C (V (P x a)) deriving Functor

data P x a = P (x a) deriving Functor

But when PolyKinds is enabled, GHC crashes with

$ ghc Bug.hs 
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:9:37:ghc: panic! (the 'impossible' happened)
  (GHC version for x86_64-unknown-linux):
	Prelude.(!!): index too large

Change History (7)

comment:1 Changed 4 years ago by ghorn

Cc: gregmainland@… added

comment:2 Changed 4 years ago by goldfire

Confirmed reproducible in HEAD.

comment:3 Changed 4 years ago by simonpj

Yes I'm on this.

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

In ffed708c30f2d1d4b4c5cd08d9c19aeb0bb623ec/ghc:

Apply the kind subst to the (kinds of the) quanitifed tyvars in deriveTyData

I've elaboated Note [Unify kinds in deriving] to explain
what is going on here.

The change fixes Trac #8893.

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

comment:6 Changed 4 years ago by simonpj

Status: newmerge
Test Case: deriving/should_compile/T8893

Thanks for an excellent test case!

Austin, please merge.


comment:7 Changed 4 years ago by thoughtpolice

Milestone: 7.8.1
Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.