#5560: case and type synonym
----------------------------+-----------------------------------------------
Reporter: sleepyMonad | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.0.2 | Keywords:
Testcase: | Blockedby:
Os: Linux | Blocking:
Architecture: x86 | Failure: Incorrect result at runtime
----------------------------+-----------------------------------------------
Observed on arch linux, 7.0.3 ghc. (package version 7.0.3-2)
The warning is suspicious; the result for switchOnEvent2 bp is wrong.
It works however if no type synonym is used (as illustrated).
Thanks
-- patrick
========================================
[patrick@eee2 launcher]$ ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :l testme
[1 of 1] Compiling Main ( testme.hs, interpreted )
testme.hs:10:1:
Warning: Pattern match(es) are overlapped
In an equation for `switchOnEvent2':
switchOnEvent2 bp = ...
switchOnEvent2 _ = ...
Ok, modules loaded: Main.
*Main> switchOnEvent2 kp
KP
*Main> switchOnEvent2 bp
KP
*Main> switchOnEvent3 202
KP
*Main> switchOnEvent3 204
BP
*Main> switchOnEvent3 203
??
*Main> >
----------------------------------------------------------------------
-- testme.hs:
import Data.Word
type MyEventType = Word32
kp :: MyEventType
kp = 102
bp :: MyEventType
bp = 104
switchOnEvent2 :: MyEventType -> IO ()
switchOnEvent2 kp = do putStrLn "KP"
switchOnEvent2 bp = do putStrLn "BP"
switchOnEvent2 _ = do putStrLn "??"
switchOnEvent3 :: Word32 -> IO ()
switchOnEvent3 202 = do putStrLn "KP"
switchOnEvent3 204 = do putStrLn "BP"
switchOnEvent3 _ = do putStrLn "??"
------------------------------------------------------
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5560>
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