Ticket #7729 (new bug)
GHC panics. Invalid core
| Reported by: | Khudyakov | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.3 |
| Component: | Compiler | Version: | 7.6.2 |
| Keywords: | Cc: | ekmett@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | indexed_types/should_fail/T7729,T7729a | Blocked By: | |
| Blocking: | Related Tickets: |
Description
Following code snippet triggers panic:
{-# LANGUAGE FlexibleContexts, TypeFamilies #-}
module Monad where
class Monad m => PrimMonad m where
type PrimState m
class MonadTrans t where
lift :: Monad m => m a -> t m a
class (PrimMonad (BasePrimMonad m), Monad m) => MonadPrim m where
type BasePrimMonad m :: * -> *
liftPrim :: BasePrimMonad m a -> m a
newtype Rand m a = Rand {
runRand :: Maybe (m ()) -> m a
}
instance (Monad m) => Monad (Rand m) where
return = Rand . const . return
(Rand rnd) >>= f = Rand $ \g -> (\x -> runRand (f x) g) =<< rnd g
instance MonadTrans Rand where
lift = Rand . const
instance MonadPrim m => MonadPrim (Rand m) where
type BasePrimMonad (Rand m) = BasePrimMonad m
liftPrim = liftPrim . lift
GHC 7.6.2 panics
$ ghc-7.6.2 -c Monad.hs
ghc: panic! (the 'impossible' happened)
(GHC version 7.6.2 for x86_64-unknown-linux):
cgLookupPanic (probably invalid Core; try -dcore-lint)
$dMonadTrans{v ahe} [lid]
static binds for:
local binds for:
main:Monad.lift{v ra} [gid[ClassOp]]
main:Monad.liftPrim{v rc} [gid[ClassOp]]
main:Monad.$p1PrimMonad{v rgv} [gid[ClassOp]]
main:Monad.$p1MonadPrim{v rgA} [gid[ClassOp]]
main:Monad.$p2MonadPrim{v rgB} [gid[ClassOp]]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
whereas 7.4.2 reports type error
$ ghc-7.4.2 -c Monad.hs
Monad.hs:28:14:
Occurs check: cannot construct the infinite type: m0 = t0 m0
Expected type: BasePrimMonad (Rand m) a -> Rand m a
Actual type: m0 a -> Rand m a
In the expression: liftPrim . lift
In an equation for `liftPrim': liftPrim = liftPrim . lift
Change History
Note: See
TracTickets for help on using
tickets.
