Panic! (the ‘impossible’ happened)—on interactive input of recursive impl. of Thue-Morse sequence (possibly elsewhere)
Summary
GHCi fails when given a specific implementation of the Thue-Morse sequence, with the following error:
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210422:
nameModule
internal t2_sKW
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
Steps to reproduce
Open a session of GHCi (with ghci
or ghc --interactive
), and type:
t = True : False : (tail t >>= \x -> [x, not x])
Notably, the above does not seem to fail if the code does not type-check (i.e. by removing tail
).
It also requires an interactive input. Compiling a file with this line or loading such a file in GHCi do not trigger this.
Expected behavior
The absence of a panic.
Environment
- GHC version used: The Glorious Glasgow Haskell Compilation System, version 9.2.0.20210422
- Operating System: Pop!_OS 21.04 on Linux 5.11.0-7620-generic
#21~1626191760~21.04~55de9c3-Ubuntu
x86_64