#1683: strange MVar / UnsafePerformIO (and type checker...) behaviour
-------------------------------+--------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6.1
Severity: normal | Keywords: MVar, UnsafePerformIO,
typechecker
Difficulty: Unknown | Os: Unknown
Testcase: | Architecture: Unknown
-------------------------------+--------------------------------------------
Compare the following two code snippets:
{{{
import Data.Word
import Control.Concurrent.MVar
import System.IO.Unsafe
a :: MVar Int
a = unsafePerformIO newEmptyMVar
b :: MVar Word8
b = unsafePerformIO newEmptyMVar
main1 = do
putMVar a (-5)
putMVar b (-127)
x <- readMVar a
y <- readMVar b
print (x,y)
}}}
and (I omitted the imports here for brevity):
{{{
gvar :: MVar a
gvar = unsafePerformIO newEmptyMVar
a :: MVar Int
a = gvar
b :: MVar Word8
b = gvar
main = do
putMVar a (-5)
x <- readMVar a
y <- readMVar b
print (x,y)
}}}
The first version works as intended (and prints `(-5,129)`). However, what
happens in the second version, that it compiles without any warnings, but
`a` and `b` becomes the same thing (prints `(-5,-5)`), even though I
declared them to have ''different types''! I'm not sure what would be the
correct behaviour, but I reckon this is not the correct one.
The effect is the same on 6.6.1 and 6.7.20070830, and was tested on an x86
machine running Mac OS X.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1683>
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