[commit: ghc] master: Haddock needs to pass visible modules for instance filtering (66961dc)
git at git.haskell.org
git at git.haskell.org
Fri Jan 26 19:40:59 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/66961dc85e39bbc43a1c065ee00c381a7ee579e1/ghc
>---------------------------------------------------------------
commit 66961dc85e39bbc43a1c065ee00c381a7ee579e1
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
>---------------------------------------------------------------
66961dc85e39bbc43a1c065ee00c381a7ee579e1
compiler/main/GHC.hs | 11 +++++++----
utils/haddock | 2 +-
2 files changed, 8 insertions(+), 5 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/utils/haddock b/utils/haddock
index 2484138..dd80ae1 160000
--- a/utils/haddock
+++ b/utils/haddock
@@ -1 +1 @@
-Subproject commit 24841386cff6fdccc11accf9daa815c2c7444d65
+Subproject commit dd80ae1773ea6aae48c3c5a899d510699783d6ee
More information about the ghc-commits
mailing list