diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-07-05 12:25:59 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-09 11:11:58 -0400 |
commit | 3609a4781f351fdef8f0987c62d72c4e8bb81959 (patch) | |
tree | 9a8e6a53dbf0a383dd189e7e8fa7de44a81ec84d /ghc | |
parent | a889bc05dfff611521769843993ccea7a0061537 (diff) | |
download | haskell-3609a4781f351fdef8f0987c62d72c4e8bb81959.tar.gz |
ghci: Fix most calls to isLoaded to work in multi-mode
The most egrarious thing this fixes is the report about the total number
of loaded modules after starting a session.
Ticket #20889
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 38cce4b1e7..82f2109ec2 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1721,7 +1721,7 @@ editFile str = -- of those. chooseEditFile :: GHC.GhcMonad m => m String chooseEditFile = - do let hasFailed (GHC.ModuleNode _deps x) = fmap not $ GHC.isLoaded $ GHC.ms_mod_name x + do let hasFailed (GHC.ModuleNode _deps x) = fmap not $ isLoadedModSummary x hasFailed _ = return False graph <- GHC.getModuleGraph @@ -2125,7 +2125,10 @@ doLoadAndCollectInfo retain_context howmuch = do doLoad retain_context howmuch >>= \case Succeeded | doCollectInfo -> do mod_summaries <- GHC.mgModSummaries <$> getModuleGraph - loaded <- filterM GHC.isLoaded $ map GHC.ms_mod_name mod_summaries + -- MP: :set +c code path only works in single package mode atm, hence + -- this call to isLoaded is ok. collectInfo needs to be modified further to + -- work with :set +c so I have punted on that for now. + loaded <- filterM GHC.isLoaded (map ms_mod_name mod_summaries) v <- mod_infos <$> getGHCiState !newInfos <- collectInfo v loaded modifyGHCiState (\st -> st { mod_infos = newInfos }) @@ -2183,7 +2186,7 @@ setContextAfterLoad keep_ctxt (Just graph) = do (m:_) -> load_this m where - is_loaded (GHC.ModuleNode _ ms) = GHC.isLoaded (ms_mod_name ms) + is_loaded (GHC.ModuleNode _ ms) = isLoadedModSummary ms is_loaded _ = return False findTarget mds t @@ -3337,7 +3340,7 @@ showModules = do getLoadedModules :: GHC.GhcMonad m => m [GHC.ModSummary] getLoadedModules = do graph <- GHC.getModuleGraph - filterM (GHC.isLoaded . GHC.ms_mod_name) (GHC.mgModSummaries graph) + filterM isLoadedModSummary (GHC.mgModSummaries graph) showBindings :: GHC.GhcMonad m => m () showBindings = do @@ -3365,6 +3368,9 @@ showBindings = do printTyThing :: GHC.GhcMonad m => TyThing -> m () printTyThing tyth = printForUser (pprTyThing showToHeader tyth) +isLoadedModSummary :: GHC.GhcMonad m => ModSummary -> m Bool +isLoadedModSummary ms = GHC.isLoadedModule (ms_unitid ms) (ms_mod_name ms) + {- Note [Filter bindings] ~~~~~~~~~~~~~~~~~~~~~~ |