-drule-check causes panic
Summary
I found a panic when using -drule-check
.
Steps to reproduce
module ConcatMap where
data Stream a = forall s. Stream (s -> ()) s
concatMapS :: (a -> Stream b) -> Stream a -> Stream b
concatMapS f (Stream next0 s0) = Stream undefined undefined
{-# INLINE [1] concatMapS #-}
concatMapS' :: (s -> ()) -> (a -> s) -> Stream a -> Stream b
concatMapS' = undefined
{-# RULES "concatMap" forall step f. concatMapS (\x -> Stream step (f x)) = concatMapS' step f #-}
replicateStep :: a -> b
replicateStep _ = undefined
{-# INLINE replicateStep #-}
replicateS :: Int -> a -> Stream a
replicateS n x0 = Stream replicateStep undefined
{-# INLINE replicateS #-}
foo1 :: Stream Int -> Stream Int
foo1 = concatMapS (replicateS 2)
Compiling that with -drule-check concatMap
yields this panic:
==================== Rule check ====================
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.8.2:
lookupIdSubst
replicateStep
InScope {eta_B0 eta_B1 step_axK f_axL a_aSh k_aTj b_aTl t_aTv s_aTD
replicateS foo1_sWM foo1_sWN}
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:191:37 in ghc-9.8.2-b74f:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Subst.hs:197:17 in ghc-9.8.2-b74f:GHC.Core.Subst
CallStack (from HasCallStack):
panic, called at compiler/GHC/Utils/Error.hs:503:29 in ghc-9.8.2-b74f:GHC.Utils.Error
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Expected behavior
No panic.
Environment
- GHC version used: 9.8.2