From 19deb002daa74de15cebaae3d861e6f2f932f7fd Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Thu, 10 Feb 2022 12:28:21 +0000 Subject: Refine tcSemigroupWarnings to work in ghc-prim ghc-prim doesn't depend on base so can't have any Monoid or Semigroup instances. However, attempting to load these definitions ran into issues when the interface for `GHC.Base` did exist as that would try and load the interface for `GHC.Types` (which is the module we are trying to compile and has no interface). The fix is to just not do this check when we are compiling a module in ghc-prim. Fixes #21069 --- compiler/GHC/Tc/Module.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs index 34a02e70ec..026686b8cc 100644 --- a/compiler/GHC/Tc/Module.hs +++ b/compiler/GHC/Tc/Module.hs @@ -1560,10 +1560,13 @@ tcTopSrcDecls _ = panic "tcTopSrcDecls: ValBindsIn" tcSemigroupWarnings :: TcM () tcSemigroupWarnings = do - traceTc "tcSemigroupWarnings" empty - let warnFlag = Opt_WarnSemigroup - tcPreludeClashWarn warnFlag sappendName - tcMissingParentClassWarn warnFlag monoidClassName semigroupClassName + mod <- getModule + -- ghc-prim doesn't depend on base + unless (moduleUnit mod == primUnit) $ do + traceTc "tcSemigroupWarnings" empty + let warnFlag = Opt_WarnSemigroup + tcPreludeClashWarn warnFlag sappendName + tcMissingParentClassWarn warnFlag monoidClassName semigroupClassName -- | Warn on local definitions of names that would clash with future Prelude -- cgit v1.2.1