Skip to content

All dependent files are recompiled on a save #4511

Open
@mpickering

Description

@mpickering

When a save a file, recompilation is triggered for all the files which depend on the file I saved.

I tracked down the bug to the fact that

  1. Interfaces are created with -haddock option set.
  2. Recompilation checking is run in a context where -haddock is not set.

This seems to be complicated with all the logic with turning -haddock on in some situations and not in others.

The following diff "fixes" the immediate problem for me, but I don't know if there are some situations where interfaces are created without -haddock being enabled.

--- a/ghcide/src/Development/IDE/Core/Compile.hs
+++ b/ghcide/src/Development/IDE/Core/Compile.hs
@@ -1275,7 +1275,7 @@ loadInterface
   -> RecompilationInfo m
   -> m ([FileDiagnostic], Maybe HiFileResult)
 loadInterface session ms linkableNeeded RecompilationInfo{..} = do
-    let sessionWithMsDynFlags = hscSetFlags (ms_hspp_opts ms) session
+    let sessionWithMsDynFlags = hscSetFlags (gopt_set (ms_hspp_opts ms) Opt_Haddock) session
         mb_old_iface = hirModIface . fst <$> old_value
         mb_old_version = snd <$> old_value

It would be simpler if the options chosen to compile a file were fixed at the start of compilation and not modified in ad-hoc places later on.

In my opinion this is a serious bug.

Metadata

Metadata

Assignees

Labels

component: ghcidepriority: highHigh priority itemtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions