Skip to content

Commit a415b32

Browse files
committed
When checking for home unit closure, only include the actual home units in the project.
GHC gives a default "main" home unit, and it is difficult to avoid this as each ghc session must have an active home unit at all times, but in a multiple component session, there is no other good choice for a default unit. We could pick one arbitrarily, but this is ugly and complicates the code a lot. We never use this default "main" unit for anything, as the GHC sessions corresponding to any file/component have the active unit set to the correct one for that component. When checking for home unit closure, we must make sure to include only the actual units in the project, not the bogus "main" unit that GHC forces us to have. Including the main unit seems to make the `checkHomeUnitsClosed` loop forever for some reason. Fixes #4046
1 parent b377ab3 commit a415b32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: ghcide/session-loader/Development/IDE/Session.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -821,12 +821,13 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
821821
mkMap = Map.fromListWith unionCIs . map (\ci -> (componentUnitId ci, ci))
822822
let dfs = map componentDynFlags $ Map.elems cis
823823
uids = Map.keys cis
824+
uids_set = Map.keysSet cis
824825
logWith recorder Info $ LogMakingNewHscEnv uids
825826
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
826827
Compat.initUnits dfs hsc_env
827828

828829
#if MIN_VERSION_ghc(9,3,0)
829-
let closure_errs = checkHomeUnitsClosed (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv') pkg_deps
830+
let closure_errs = checkHomeUnitsClosed (hsc_unit_env hscEnv') uids_set pkg_deps
830831
pkg_deps = do
831832
home_unit_id <- uids
832833
home_unit_env <- maybeToList $ unitEnv_lookup_maybe home_unit_id $ hsc_HUG hscEnv'

0 commit comments

Comments
 (0)