[GHC] #16312: Optimization + adding an INLINE pragma triggers Core Lint error (Type of case alternatives not the same as the annotation on case)

#16312: Optimization + adding an INLINE pragma triggers Core Lint error (Type of
case alternatives not the same as the annotation on case)
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Compile-time
Unknown/Multiple | crash or panic
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Here's a seemingly innocuous program, minimized from the `kan-extensions`
library:
{{{#!hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
module Bug where
newtype Curried g h a =
Curried { runCurried :: forall r. g (a -> r) -> h r }
instance Functor g => Functor (Curried g h) where
fmap f (Curried g) = Curried (g . fmap (.f))
instance (Functor g, g ~ h) => Applicative (Curried g h) where
pure a = Curried (fmap ($a))
Curried mf <*> Curried ma = Curried (ma . mf . fmap (.))
{-# INLINE (<*>) #-}
-- The Core Lint error goes away if you remove this INLINE pragma
}}}
However, it triggers a Core Lint error on GHC 8.2.2 through HEAD if you
compile it with `-O` and `-dcore-lint`:
{{{
$ /opt/ghc/8.6.3/bin/ghc -fforce-recomp -dcore-lint Bug.hs -O
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
In the expression: (case heq_sel
@ (* -> *)
@ (* -> *)
@ h_a1eC
@ h_a1eC
($d~_a1eE
`cast` (((~) <* -> *>_N co_a1hx

#16312: Optimization + adding an INLINE pragma triggers Core Lint error (Type of case alternatives not the same as the annotation on case) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * Attachment "ghc-8.6.3.dump-core-lint" added. Result of running `/opt/ghc/8.6.3/bin/ghc -fforce-recomp -dcore-lint Bug.hs -O` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16312 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16312: Optimization + adding an INLINE pragma triggers Core Lint error (Type of case alternatives not the same as the annotation on case) -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Definite bug here! I investigated a bit. Here's a simpler example that crashes in the same way. {{{ {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes, KindSignatures #-} module Bug where import GHC.Base data Curried (g :: * -> *) (h :: * -> *) a instance Functor (Curried g h) where fmap = error "urk2" instance (g ~ h) => Applicative (Curried g h) where pure = error "urk" liftA2 = error "urk" (<*) = error "urk" (*>) = error "urk" (<*>) = grstargr wib :: (g ~ h) => Curried g h (b->b) -> Curried g h b -> Curried g h b wib a1 a2 = a1 <*> a2 grstargr :: Curried g h (a->b) -> Curried g h a -> Curried g h b {-# NOINLINE grstargr #-} grstargr = error "urk" }}} I'm pretty sure that the wrong-ness is that the result type attached to a `Case` in Core is getting out of date. I don't yet know how though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16312#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC