[commit: ghc] ghc-8.4: Haddock needs to pass visible modules for instance filtering (42a82cf)
git at git.haskell.org
git at git.haskell.org
Sat Feb 3 16:58:13 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.4
Link : http://ghc.haskell.org/trac/ghc/changeset/42a82cf4c8fa95195b4ab55795c919512f92d5f4/ghc
>---------------------------------------------------------------
commit 42a82cf4c8fa95195b4ab55795c919512f92d5f4
Author: Alec Theriault <alec.theriault at gmail.com>
Date: Fri Jan 26 13:05:31 2018 -0500
Haddock needs to pass visible modules for instance filtering
The GHC-side `getNameToInstancesIndex` filters out incorrectly some
instances because it is not aware of what modules are visible. Using
`runTcInteractive` means that `ie_visible` gets initialized to a one
module set containing some dummy GHCi module. This is clearly not the
module set we want to check against to see if a given orphan instance
is visible or not.
In fact, GHC has no way of knowing what we want that module set to be
since it doesn't know ahead of time which modules Haddock is making its
docs for. The fix is just to pass that set in as an argument.
Bumps haddock submodule.
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: duog, alexbiehl, rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4290
(cherry picked from commit a47438e88e685971a81874565f2914043c8233c3)
>---------------------------------------------------------------
42a82cf4c8fa95195b4ab55795c919512f92d5f4
compiler/main/GHC.hs | 11 +++++++----
testsuite/tests/perf/haddock/all.T | 3 ++-
utils/haddock | 2 +-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 343ef37..1e54f0e 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -1244,12 +1244,15 @@ getGRE = withSession $ \hsc_env-> return $ ic_rn_gbl_env (hsc_IC hsc_env)
-- by 'Name'. Each name's lists will contain every instance in which that name
-- is mentioned in the instance head.
getNameToInstancesIndex :: GhcMonad m
- => m (Messages, Maybe (NameEnv ([ClsInst], [FamInst])))
-getNameToInstancesIndex = do
+ => [Module] -- ^ visible modules. An orphan instance will be returned if and
+ -- only it is visible from at least one module in the list.
+ -> m (Messages, Maybe (NameEnv ([ClsInst], [FamInst])))
+getNameToInstancesIndex visible_mods = do
hsc_env <- getSession
liftIO $ runTcInteractive hsc_env $
do { loadUnqualIfaces hsc_env (hsc_IC hsc_env)
- ; InstEnvs {ie_global, ie_local, ie_visible} <- tcGetInstEnvs
+ ; InstEnvs {ie_global, ie_local} <- tcGetInstEnvs
+ ; let visible_mods' = mkModuleSet visible_mods
; (pkg_fie, home_fie) <- tcGetFamInstEnvs
-- We use Data.Sequence.Seq because we are creating left associated
-- mappends.
@@ -1257,7 +1260,7 @@ getNameToInstancesIndex = do
; let cls_index = Map.fromListWith mappend
[ (n, Seq.singleton ispec)
| ispec <- instEnvElts ie_local ++ instEnvElts ie_global
- , instIsVisible ie_visible ispec
+ , instIsVisible visible_mods' ispec
, n <- nameSetElemsStable $ orphNamesOfClsInst ispec
]
; let fam_index = Map.fromListWith mappend
diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T
index b7e6b21..576ac38 100644
--- a/testsuite/tests/perf/haddock/all.T
+++ b/testsuite/tests/perf/haddock/all.T
@@ -69,7 +69,7 @@ test('haddock.Cabal',
[extra_files(['../../../../libraries/Cabal/Cabal/dist-install/haddock.t']),
unless(in_tree_compiler(), skip), req_haddock
,stats_num_field('bytes allocated',
- [(wordsize(64), 20104611952, 5)
+ [(wordsize(64), 25699561072, 5)
# 2012-08-14: 3255435248 (amd64/Linux)
# 2012-08-29: 3324606664 (amd64/Linux, new codegen)
# 2012-10-08: 3373401360 (amd64/Linux)
@@ -121,6 +121,7 @@ test('haddock.Cabal',
# 2017-11-02: 17133915848 (amd64/Linux) - Phabricator D4144
# 2017-11-06: 18936339648 (amd64/Linux) - Unknown
# 2017-11-09: 20104611952 (amd64/Linux) - Bump Cabal
+ # 2018-02-03: 25699561072 (x86_64/Linux) - Bump haddock submodule
,(platform('i386-unknown-mingw32'), 3293415576, 5)
# 2012-10-30: 1733638168 (x86/Windows)
diff --git a/utils/haddock b/utils/haddock
index e329a73..ac33472 160000
--- a/utils/haddock
+++ b/utils/haddock
@@ -1 +1 @@
-Subproject commit e329a73765c510774e3a3f54472bcdeca48613f6
+Subproject commit ac33472e834d381f95fd56586e57e6653263055c
More information about the ghc-commits
mailing list