cgEvalAlts
Wolfgang Thaller
wolfgang.thaller at gmx.net
Tue Feb 10 12:30:27 EST 2004
I'm currently stuck.
CgCase.cgEvalAlts gets invoked with a PrimAlt alt_type (second equation
of cgEvalAlts) where the (tyConArgRep tycon) is VoidArg, and so it
panics. The scrutinee of the case expression is the return value of
putMVar#, which is a State#.
I don't know all that case alternatives code generation magic well
enough to extend cgEvalAlts to handle void scrutinees.
It doesn't always happen when putMVar# is used, but I don't know why
not.
Below you'll find a cut-down module that only depends on GHC.Prim and
GHC.Base to reproduce the problem.
Cheers,
Wolfgang
-- cut here --
{-# OPTIONS -fno-implicit-prelude -fglasgow-exts -O -fasm #-}
module CgEvalAltsPanic where
import GHC.Prim
import GHC.Base
-- from GHC.IOBase
newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))
unIO :: IO a -> (State# RealWorld -> (# State# RealWorld, a #))
unIO (IO a) = a
thenIO :: IO a -> IO b -> IO b
thenIO (IO m) k = IO ( \ s ->
case m s of
(# new_s, a #) -> unIO k new_s
)
-- slightly simplified :-)
data Exception = Foo | Bar
-- from GHC.Conc
data MVar a = MVar (MVar# RealWorld a)
putMVar :: MVar a -> a -> IO ()
putMVar (MVar mvar#) x = IO $ \ s# ->
case putMVar# mvar# x s# of
s2# -> (# s2#, () #)
-- this triggers the problem
bug :: MVar a -> a -> Exception -> IO ()
bug m h_ err = putMVar m h_ `thenIO` case err of
Foo -> IO (raiseIO# err)
_ -> IO (raiseIO# err)
More information about the Cvs-ghc
mailing list