Overlapping data instances can segfault
When exploring data families for some fast unboxed tuple representation, we came across the following scenario.
class Foo a where
data Bar a :: *
instance Foo a where
data Bar a = PBar a
instance Foo () where
data Bar () = PUnit
GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( Foo.hs, interpreted )
Ok, modules loaded: Main.
*Main> case PUnit of PBar x -> x
Segmentation fault
It appears the compiler is allowing the refinement of a into () because they overlap, when it shouldn't.
This is less academic than this example, because it affects doing similar operations to automatically unbox tuples of primitives when possible.
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett@gmail.com |
Operating system | |
Architecture |