#2677: Detection of TF instance conflict depends on instance order
----------------------------------------+-----------------------------------
Reporter: reinerp | Owner: chak
Type: bug | Status: closed
Priority: normal | Milestone: 6.12 branch
Component: Compiler (Type checker) | Version: 6.10.3
Severity: critical | Resolution: fixed
Keywords: TF instance conflict | Difficulty: Unknown
Testcase: T2677 | Os: Linux
Architecture: x86_64 (amd64) |
----------------------------------------+-----------------------------------
Changes (by dorchard):
* version: 6.9 => 6.10.3
* os: Unknown/Multiple => Linux
* architecture: Unknown/Multiple => x86_64 (amd64)
* severity: normal => critical
Comment:
Just discovered this bug today but glad to see it has already been picked
up.
The bug applies to data families too. You can do some pretty whacked out
stuff with this bug, like launching missiles ;)
{{{
{-# LANGUAGE TypeFamilies #-}
-- MkFoo is a constructor on pure functions thereore "safe" :)
data family Foo a
data instance Foo a = MkFoo (Int -> Int)
unBox :: Foo a -> (Int -> Int)
unBox (MkFoo x) = x
-- Nasty person adds this code in a module
launchMissiles :: IO ()
launchMissiles = print ("Launching missiles...")
data instance Foo Int = MakeLauncher (IO())
launch = (unBox (MakeLauncher launchMissiles)) 42
}}}
launch segfaults, but about 1 in 3 times (depending on the memory layout)
the missiles are launched!
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2677#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs