GHCi panic when consing onto self
Summary
GHCi seems to dislike self-reference and list cons.
Steps to reproduce
I initially had this happen when trying to write xs = 1 : fmap (+1) xs
.
λ ~/Projects/production-haskell/ master* ghci
GHCi, version 9.2.0.20210422: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/matt/.dotfiles/haskell/ghci.symlink
λ> xs = 1 : fmap (+1) xs
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210422:
nameModule
internal xs2_sCN
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/Types/Name.hs:323:3 in ghc:GHC.Types.Name
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
I managed to reduce this to
l = () : l
Using let
doesn't help.
Using fix
does -
l = fix $ \self -> () : self
Using mappend
or ++
doesn't cause the issue. Using cons = (:)
and then writing a = cons 1 a
also works!
Expected behavior
Compile and work
Environment
- GHC version used: 9.2.0.20210422 from ghcup
Optional:
- Operating System:
- System Architecture: