refineInScope panic on rewriteRule
Summary
Panic when compiling text-ansi
from hackage, reduced example below.
Steps to reproduce
Code.hs
:
module Text.Builder.ANSI
( -- $intro
surround,
)
where
import Data.Text.Builder.Linear (Builder)
import qualified Data.Text.Builder.Linear as Builder
--------------------------------------------------------------------------------
surround :: Builder -> Builder -> Builder
surround _ text = text
{-# NOINLINE [1] surround #-}
semi :: Builder
semi = Builder.fromChar ';'
-- Collapse surround/surround to a single surround before phase 1
{-# RULES
"surround/surround" [~1] forall a b s.
surround a (surround b s) =
surround (a <> semi <> b) s
#-}
Compile with:
$ nix shell --impure --expr 'with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/f3dab3509afca932f3f4fd0908957709bb1c1f57.tar.gz) {}; haskell.packages.ghc928.ghc.withPackages (h: [h.text_2_0_2 (h.text-builder-linear.override { text = h.text_2_0_2; })])' -c ghc -O1 Code.hs
[1 of 1] Compiling Text.Builder.ANSI ( Code.hs, Code.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.8:
refineFromInScope
InScope {wild_00 a_ass b_ast s_asu x_aIM b_aQa surround $trModule
ds1_sQg $trModule_sQh $trModule_sQi $trModule_sQj $trModule_sQk}
semi_sLg
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Core/Opt/Simplify/Env.hs:706:30 in ghc:GHC.Core.Opt.Simplify.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Expected behavior
It should not panic
Environment
- GHC version used: 9.2.8
Optional:
- Operating System: ArchLinux
- System Architecture: x86_64-linux