GHC panic with duplicate exports due to record pattern synonym
Summary
GHC panics when a duplicate export is from a record pattern synonym and another module attempts to import it.
Steps to reproduce
With these two files:
bad1.hs:
{-# LANGUAGE PatternSynonyms #-}
module Bad1 (T(TSyn, getTSyn), getTSyn) where
data T = T Int
pattern TSyn :: Int -> T
pattern TSyn {getTSyn} <- T getTSyn where
TSyn i = T i
bad2.hs:
module Bad2 where
import Bad1 (getTSyn)
Run ghc ./bad1.hs ./bad2.hs
should result in this output:
bad1.hs:3:32: warning: [-Wduplicate-exports]
‘getTSyn’ is exported by ‘getTSyn’ and ‘T(TSyn, getTSyn)’
|
3 | module Bad1 (T(TSyn, getTSyn), getTSyn) where
| ^^^^^^^
[2 of 2] Compiling Bad2 ( bad2.hs, bad2.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.4 for x86_64-unknown-linux):
filterImports/combine
(getTSyn, getTSyn, Nothing)
(getTSyn, T{T, TSyn, getTSyn;}, Nothing)
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/rename/RnNames.hs:899:23 in ghc:RnNames
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Expected behavior
This should be accepted, since the exporting module compiled
Environment
- GHC version used: 8.8.4
Optional:
- Operating System: Linux (NixOS)
- System Architecture: AMD64