summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2021-02-06 23:26:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-22 18:27:08 -0500
commitc7e801991dc9d4f702e92caf6d6347bbff6a8f3c (patch)
tree68f439d34ccb215df980a1f366b27d875d2012c9 /compiler/GHC/Unit
parent58897e2423cd120fbb32eda87f63aa56540a033f (diff)
downloadhaskell-c7e801991dc9d4f702e92caf6d6347bbff6a8f3c.tar.gz
ModuleOrigin: print details of module conflict
Before the change the error did not show details of involved module: ``` haddock: panic! (the 'impossible' happened) (GHC version 8.10.3: ModOrigin: hidden module redefined ``` After the change modile details are shown: ``` ghc-stage1: panic! (the 'impossible' happened) (GHC version 9.1.20210206: ModOrigin: package both exposed/hidden x: exposed package y: reexport by ghc-boot-9.1 ``` Fixes #19330 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'compiler/GHC/Unit')
-rw-r--r--compiler/GHC/Unit/State.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs
index cefa5e5058..92b38443c8 100644
--- a/compiler/GHC/Unit/State.hs
+++ b/compiler/GHC/Unit/State.hs
@@ -224,14 +224,16 @@ fromFlag :: ModuleOrigin
fromFlag = ModOrigin Nothing [] [] True
instance Semigroup ModuleOrigin where
- ModOrigin e res rhs f <> ModOrigin e' res' rhs' f' =
+ x@(ModOrigin e res rhs f) <> y@(ModOrigin e' res' rhs' f') =
ModOrigin (g e e') (res ++ res') (rhs ++ rhs') (f || f')
where g (Just b) (Just b')
| b == b' = Just b
- | otherwise = panic "ModOrigin: package both exposed/hidden"
+ | otherwise = pprPanic "ModOrigin: package both exposed/hidden" $
+ text "x: " <> ppr x $$ text "y: " <> ppr y
g Nothing x = x
g x Nothing = x
- _x <> _y = panic "ModOrigin: hidden module redefined"
+ x <> y = pprPanic "ModOrigin: hidden module redefined" $
+ text "x: " <> ppr x $$ text "y: " <> ppr y
instance Monoid ModuleOrigin where
mempty = ModOrigin Nothing [] [] False