Skip to content

Commit 2084203

Browse files
committed
Fix multiple components by using consistent UnitIds
There are multiple sources of truth for the home unit id now, in the DynFlags and in the hsc_units
1 parent 6691075 commit 2084203

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
432432
newHscEnv <-
433433
-- Add the options for the current component to the HscEnv
434434
evalGhcEnv hscEnv $ do
435-
_ <- setSessionDynFlags df
435+
_ <- setSessionDynFlags $ setHomeUnitId_ fakeUid df
436436
getSession
437437

438438
-- Modify the map so the hieYaml now maps to the newly created

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,23 @@ typecheckModule :: IdeDefer
147147
-> ParsedModule
148148
-> IO (IdeResult TcModuleResult)
149149
typecheckModule (IdeDefer defer) hsc keep_lbls pm = do
150-
fmap (either (,Nothing) id) $
151-
catchSrcErrors (hsc_dflags hsc) "typecheck" $ do
152-
153150
let modSummary = pm_mod_summary pm
154151
dflags = ms_hspp_opts modSummary
155-
156152
modSummary' <- initPlugins hsc modSummary
157-
(warnings, tcm) <- withWarnings "typecheck" $ \tweak ->
153+
(warnings, etcm) <- withWarnings "typecheck" $ \tweak ->
158154
let
159155
session = tweak (hscSetFlags dflags hsc)
160156
-- TODO: maybe settings ms_hspp_opts is unnecessary?
161157
mod_summary'' = modSummary' { ms_hspp_opts = hsc_dflags session}
162158
in
163-
tcRnModule session keep_lbls $ demoteIfDefer pm{pm_mod_summary = mod_summary''}
159+
catchSrcErrors (hsc_dflags hsc) "typecheck" $ do
160+
tcRnModule session keep_lbls $ demoteIfDefer pm{pm_mod_summary = mod_summary''}
164161
let errorPipeline = unDefer . hideDiag dflags . tagDiag
165162
diags = map errorPipeline warnings
166163
deferedError = any fst diags
167-
return (map snd diags, Just $ tcm{tmrDeferedError = deferedError})
164+
case etcm of
165+
Left errs -> return ((map snd diags) ++ errs, Nothing)
166+
Right tcm -> return (map snd diags, Just $ tcm{tmrDeferedError = deferedError})
168167
where
169168
demoteIfDefer = if defer then demoteTypeErrorsToWarnings else id
170169

@@ -213,7 +212,7 @@ tcRnModule hsc_env keep_lbls pmod = do
213212
unload hsc_env_tmp keep_lbls
214213

215214
((tc_gbl_env, mrn_info), splices)
216-
<- liftIO $ captureSplices (hscSetFlags (ms_hspp_opts ms) hsc_env) $ \hsc_env_tmp ->
215+
<- liftIO $ captureSplices hsc_env_tmp $ \hsc_env_tmp ->
217216
do hscTypecheckRename hsc_env_tmp ms $
218217
HsParsedModule { hpm_module = parsedSource pmod,
219218
hpm_src_files = pm_extra_src_files pmod,

0 commit comments

Comments
 (0)