
#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