[Git][ghc/ghc][master] dump-decls: fix "Ambiguous module name"-error

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Aug 22 12:09:55 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00
dump-decls: fix "Ambiguous module name"-error

Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package.

```
dump-decls: <no location info>: error:
    Ambiguous module name `System.Console.ANSI.Types':
      it was found in multiple packages:
      ansi-terminal-0.11.4 ansi-terminal-types-0.11.5
```

- - - - -


1 changed file:

- utils/dump-decls/Main.hs


Changes:

=====================================
utils/dump-decls/Main.hs
=====================================
@@ -6,7 +6,8 @@ import GHC.Core.Class (classMinimalDef)
 import GHC.Core.TyCo.FVs (tyConsOfType)
 import GHC.Driver.Ppr (showSDocForUser)
 import GHC.Unit.State (lookupUnitId, lookupPackageName)
-import GHC.Unit.Info (UnitInfo, unitExposedModules, PackageName(..))
+import GHC.Unit.Info (UnitInfo, unitExposedModules, unitId, PackageName(..))
+import GHC.Unit.Types (UnitId)
 import GHC.Data.FastString (fsLit)
 import GHC.Driver.Env (hsc_units, hscEPS)
 import GHC.Utils.Outputable
@@ -163,14 +164,14 @@ reportUnitDecls :: UnitInfo -> Ghc SDoc
 reportUnitDecls unit_info = do
     let exposed :: [ModuleName]
         exposed = map fst (unitExposedModules unit_info)
-    vcat <$> mapM reportModuleDecls exposed
+    vcat <$> mapM (reportModuleDecls $ unitId unit_info) exposed
 
-reportModuleDecls :: ModuleName -> Ghc SDoc
-reportModuleDecls modl_nm
+reportModuleDecls :: UnitId -> ModuleName -> Ghc SDoc
+reportModuleDecls unit_id modl_nm
   | modl_nm `elem` ignoredModules = do
       return $ vcat [ mod_header, text "-- ignored", text "" ]
   | otherwise = do
-    modl <- GHC.lookupQualifiedModule NoPkgQual modl_nm
+    modl <- GHC.lookupQualifiedModule (OtherPkg unit_id) modl_nm
     mb_mod_info <- GHC.getModuleInfo modl
     mod_info <- case mb_mod_info of
       Nothing -> fail "Failed to find module"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f861423bc48045a6f907ef794eac0111754fe058

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f861423bc48045a6f907ef794eac0111754fe058
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230822/ac67c320/attachment-0001.html>


More information about the ghc-commits mailing list