Skip to content

Commit 8edf8ef

Browse files
committed
Prefer non-boot files when creating the FinderCache.
Boot files in the finder cache can lead to uneccesary linking errors like https://gitlab.haskell.org/ghc/ghc/-/issues/19816 when we actually have a non-boot file in scope.
1 parent feb5965 commit 8edf8ef

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ captureSplicesAndDeps TypecheckHelpers{..} env k = do
361361
#if MIN_VERSION_ghc(9,3,0)
362362
-- TODO: support backpack
363363
nodeKeyToInstalledModule :: NodeKey -> Maybe InstalledModule
364+
nodeKeyToInstalledModule (NodeKey_Module (ModNodeKeyWithUid (GWIB mod IsBoot) uid)) = Nothing
364365
nodeKeyToInstalledModule (NodeKey_Module (ModNodeKeyWithUid (GWIB mod _) uid)) = Just $ mkModule uid mod
365366
nodeKeyToInstalledModule _ = Nothing
366367
moduleToNodeKey :: Module -> NodeKey
@@ -1073,11 +1074,16 @@ mergeEnvs env (ms, deps) extraMods envs = do
10731074
combineModules a b
10741075
| HsSrcFile <- mi_hsc_src (hm_iface a) = a
10751076
| otherwise = b
1077+
1078+
-- Prefer non-boot files
1079+
combineModuleLocations a@(InstalledFound ml m) b | Just fp <- ml_hs_file ml, not ("boot" `isSuffixOf` fp) = a
1080+
combineModuleLocations _ b = b
1081+
10761082
concatFC :: FinderCacheState -> [FinderCache] -> IO FinderCache
10771083
concatFC cur xs = do
10781084
fcModules <- mapM (readIORef . fcModuleCache) xs
10791085
fcFiles <- mapM (readIORef . fcFileCache) xs
1080-
fcModules' <- newIORef $! foldl' (plusInstalledModuleEnv const) cur fcModules
1086+
fcModules' <- newIORef $! foldl' (plusInstalledModuleEnv combineModuleLocations) cur fcModules
10811087
fcFiles' <- newIORef $! Map.unions fcFiles
10821088
pure $ FinderCache fcModules' fcFiles'
10831089

0 commit comments

Comments
 (0)