Panic when splicing a malformed InfixE
Summary
GHC panics when splicing InfixE a op b or UInfixE a op b where op is not a variable. Related issue: #4877 (closed).
Steps to reproduce
Compiling the following file results in a panic:
-- panic.hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
main = print $(uInfixE [|1|] [|id id|] [|2|])
$ stack ghc --compiler=ghc-8.6.5 -- -fforce-recomp panic.hs
[1 of 1] Compiling Main ( panic.hs, panic.o )
Linking panic ...
Undefined symbols for architecture x86_64:
"_Main_main_closure", referenced from:
_ZCMain_main_info in panic.o
_u4lI_srt in panic.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)
The behavior is slightly different when using GHCi:
> :set -XTemplateHaskell
> import Language.Haskell.TH
> $(uInfixE [|1|] [|id id|] [|2|])
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-apple-darwin):
nameModule
internal it_a4n5
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Name.hs:240:3 in ghc:Name
Expected behavior
Not panicking.
Environment
- GHC version used: 8.6.5
Optional:
- Operating System: macOS Mojave
- System Architecture: x64