Opened 4 years ago

Closed 4 years ago

#10534 closed bug (fixed)

Data families + Coercible = unsafeCoerce

Reported by: goldfire Owned by:
Priority: highest Milestone: 7.10.2
Component: Compiler Version: 7.10.2-rc1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T10534
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D992
Wiki Page:


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.


Happily, the fix is very very simple: TyCon.isDistinctAlgRhs should return False for DataFamilyTyCons. This fix is already in-flight for HEAD in Phab:D968, but this ticket serves to correct this problem in 7.10.2 before the release.

Patch coming very shortly.

Change History (6)

comment:1 Changed 4 years ago by goldfire

Differential Rev(s): Phab:D992
Status: newpatch

comment:2 Changed 4 years ago by Richard Eisenberg <eir@…>

In 89c7168c150ccc38a2e6dd4a3aea555616722260/ghc:

Fix #10534

Test case: typecheck/should_fail/T10534

comment:3 Changed 4 years ago by goldfire

Status: patchmerge
Test Case: typecheck/should_fail/T10534

comment:4 Changed 4 years ago by simonpj

This pne-line change _really_ needs more comments. But once the next patch lands it'll have them, and we can do without on the 7.10 branch

comment:5 Changed 4 years ago by goldfire

Yes, of course. The bigger patch has run into a few validation problems that I'm working through. I fully expect to land today.

comment:6 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10, thanks Richard!

Note: See TracTickets for help on using tickets.