[commit: ghc] ghc-8.6: --show-iface: Qualify all non-local names (c69c9d3)

git at git.haskell.org git at git.haskell.org
Thu Aug 23 22:50:53 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/c69c9d399746966f5d4ffbf73f49cd768a097dbd/ghc

>---------------------------------------------------------------

commit c69c9d399746966f5d4ffbf73f49cd768a097dbd
Author: Simon Jakobi <simon.jakobi at gmail.com>
Date:   Sun Aug 12 11:10:39 2018 +0200

    --show-iface: Qualify all non-local names
    
    Summary:
    In order to disambiguate names from different modules, qualify all names
    that don't originate in the current module.
    
    Also update docs for QueryQualifyName
    
    Test Plan: validate
    
    Reviewers: simonpj, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: rwbarton, thomie, carter, tdammers
    
    GHC Trac Issues: #15269
    
    Differential Revision: https://phabricator.haskell.org/D4852
    
    (cherry picked from commit d42eef344a71990d12f27e88cdf10ba0b2a2f34b)


>---------------------------------------------------------------

c69c9d399746966f5d4ffbf73f49cd768a097dbd
 compiler/iface/LoadIface.hs                           | 18 +++++++++++++++++-
 compiler/utils/Outputable.hs                          |  8 ++------
 testsuite/tests/showIface/Orphans.stdout              | 12 ++++++------
 testsuite/tests/simplCore/should_compile/T4306.stdout |  2 +-
 testsuite/tests/simplCore/should_compile/T4918.stdout |  4 ++--
 5 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/compiler/iface/LoadIface.hs b/compiler/iface/LoadIface.hs
index 20928d6..60a9bc9 100644
--- a/compiler/iface/LoadIface.hs
+++ b/compiler/iface/LoadIface.hs
@@ -1038,6 +1038,15 @@ ifaceStats eps
                 Printing interfaces
 *                                                                      *
 ************************************************************************
+
+Note [Name qualification with --show-iface]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In order to disambiguate between identifiers from different modules, we qualify
+all names that don't originate in the current module. In order to keep visual
+noise as low as possible, we keep local names unqualified.
+
+For some background on this choice see trac #15269.
 -}
 
 -- | Read binary interface, and print it out
@@ -1048,8 +1057,15 @@ showIface hsc_env filename = do
    iface <- initTcRnIf 's' hsc_env () () $
        readBinIface IgnoreHiWay TraceBinIFaceReading filename
    let dflags = hsc_dflags hsc_env
+       -- See Note [Name qualification with --show-iface]
+       qualifyImportedNames mod _
+           | mod == mi_module iface = NameUnqual
+           | otherwise              = NameNotInScope1
+       print_unqual = QueryQualify qualifyImportedNames
+                                   neverQualifyModules
+                                   neverQualifyPackages
    putLogMsg dflags NoReason SevDump noSrcSpan
-      (defaultDumpStyle dflags) (pprModIface iface)
+      (mkDumpStyle dflags print_unqual) (pprModIface iface)
 
 -- Show a ModIface but don't display details; suitable for ModIfaces stored in
 -- the EPT.
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index 4df9adf..929c7f3 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -181,12 +181,8 @@ data PrintUnqualified = QueryQualify {
     queryQualifyPackage :: QueryQualifyPackage
 }
 
--- | given an /original/ name, this function tells you which module
--- name it should be qualified with when printing for the user, if
--- any.  For example, given @Control.Exception.catch@, which is in scope
--- as @Exception.catch@, this function will return @Just "Exception"@.
--- Note that the return value is a ModuleName, not a Module, because
--- in source code, names are qualified by ModuleNames.
+-- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify
+-- it.
 type QueryQualifyName = Module -> OccName -> QualifyName
 
 -- | For a given module, we need to know whether to print it with
diff --git a/testsuite/tests/showIface/Orphans.stdout b/testsuite/tests/showIface/Orphans.stdout
index d61a5c9..63fcd79 100644
--- a/testsuite/tests/showIface/Orphans.stdout
+++ b/testsuite/tests/showIface/Orphans.stdout
@@ -1,6 +1,6 @@
-instance [orphan] IsList [Bool] = $fIsListBool
-instance IsList [X] = $fIsListX
-family instance Item [X] = D:R:ItemX
-family instance [orphan] Item [Bool] = D:R:ItemBool
-"myrule1" [orphan] forall @ a id @ (a -> a) (id @ a) = id @ a
-"myrule2" forall id @ (X -> X) f = f
+instance [orphan] GHC.Exts.IsList [GHC.Types.Bool] = $fIsListBool
+instance GHC.Exts.IsList [X] = $fIsListX
+family instance GHC.Exts.Item [X] = D:R:ItemX
+family instance [orphan] GHC.Exts.Item [GHC.Types.Bool]
+"myrule1" [orphan] forall @ a
+"myrule2" forall GHC.Base.id @ (X -> X) f = f
diff --git a/testsuite/tests/simplCore/should_compile/T4306.stdout b/testsuite/tests/simplCore/should_compile/T4306.stdout
index 3d52e94..b2a93ff 100644
--- a/testsuite/tests/simplCore/should_compile/T4306.stdout
+++ b/testsuite/tests/simplCore/should_compile/T4306.stdout
@@ -1 +1 @@
-  $wupd :: Double# -> Double#
+  $wupd :: GHC.Prim.Double# -> GHC.Prim.Double#
diff --git a/testsuite/tests/simplCore/should_compile/T4918.stdout b/testsuite/tests/simplCore/should_compile/T4918.stdout
index 257dbb5..4e957c0 100644
--- a/testsuite/tests/simplCore/should_compile/T4918.stdout
+++ b/testsuite/tests/simplCore/should_compile/T4918.stdout
@@ -1,2 +1,2 @@
-  {- HasNoCafRefs, Strictness: m, Unfolding: (C# 'p'#) -}
-  {- HasNoCafRefs, Strictness: m, Unfolding: (C# 'q'#) -}
+  {- HasNoCafRefs, Strictness: m, Unfolding: (GHC.Types.C# 'p'#) -}
+  {- HasNoCafRefs, Strictness: m, Unfolding: (GHC.Types.C# 'q'#) -}



More information about the ghc-commits mailing list