GHC Panic With Injective Type Families
The following causes GHC to panic:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilyDependencies #-}
module T where
import GHC.TypeLits
data T1 = T1
type T2 = TypeError (Text "You can't do that!")
type family X i = r | r -> i where
X 1 = T1
X 2 = T2
$ ghc T.hs
[1 of 1] Compiling T ( T.hs, T.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for x86_64-unknown-linux):
isInjectiveTyCon sees a TcTyCon T2
This may be related to #11560 (closed). Without injectivity it gives the expected type error with the message "You can't do that!"
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module T where
import GHC.TypeLits
data T1 = T1
type T2 = TypeError (Text "You can't do that!")
type family X i where
X 1 = T1
X 2 = T2
$ ghc T.hs
[1 of 1] Compiling T ( T.hs, T.o )
T.hs:9:1: error:
• You can't do that
• In the type synonym declaration for ‘T2’
This isn't something anyone would intentionally write, as it could never type check with the type synonym T2 being a TypeError, but a panic is a panic so I said I'd raise it anyway.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |