Skip to content

Panic when wrongly using a type family as return types for GADTs

The following code causes the following panic:

{-# LANGUAGE TypeFamilies, GADTs #-}

type family F a

data G1 a where
  G1C :: F Int

data G2 a where
  G2C :: F Int
ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.0.20120810 for x86_64-apple-darwin):
	compiler/typecheck/TcTyClsDecls.lhs:1081:5-62: Irrefutable pattern failed for pattern Data.Maybe.Just subst

Admittedly, the code causing the panic is silly, but it happened to me as I was refactoring. Having two separate GADTs with the wrong return types seems necessary to cause the panic.

Trac metadata
Trac field Value
Version 7.6.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information