Data families + Coercible = unsafeCoerce
When I say
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module A where
import Data.Coerce
data family DF a
silly :: Coercible (DF a) (DF b) => a -> b
silly = coerce
{-# LANGUAGE TypeFamilies #-}
module B where
import A
newtype instance DF a = MkDF ()
unsafeCoerce :: a -> b
unsafeCoerce = silly
I get
[1 of 2] Compiling A ( A.hs, interpreted )
[2 of 2] Compiling B ( B.hs, interpreted )
Ok, modules loaded: A, B.
Eep!
Happily, the fix is very very simple: TyCon.isDistinctAlgRhs
should return False
for DataFamilyTyCon
s. This fix is already in-flight for HEAD in D968, but this ticket serves to correct this problem in 7.10.2 before the release.
Patch coming very shortly.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.2-rc1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | highest |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |