Skip to content

Commit 0f3eeac

Browse files
authored
Log a warning for every diagnostic received when doDiagnostics=False (#1537)
Even if the rule body does not produce diagnostics, it is still possible to get a BadDependency diagnostic. To avoid a debugging nightmare if this ever happens, let's make sure to log any unexpected diagnostics
1 parent 3995f3a commit 0f3eeac

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ defineEarlyCutoff'
938938
-> Action (Maybe BS.ByteString, IdeResult v)
939939
-> Action (RunResult (A (RuleResult k)))
940940
defineEarlyCutoff' doDiagnostics key file old mode action = do
941-
extras@ShakeExtras{state, inProgress} <- getShakeExtras
941+
extras@ShakeExtras{state, inProgress, logger} <- getShakeExtras
942942
options <- getIdeOptions
943943
(if optSkipProgress options key then id else withProgressVar inProgress file) $ do
944944
val <- case old of
@@ -974,8 +974,9 @@ defineEarlyCutoff' doDiagnostics key file old mode action = do
974974
(toShakeValue ShakeResult bs, Failed b)
975975
Just v -> pure (maybe ShakeNoCutoff ShakeResult bs, Succeeded (vfsVersion =<< modTime) v)
976976
liftIO $ setValues state key file res (Vector.fromList diags)
977-
when doDiagnostics $
978-
updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) diags
977+
if doDiagnostics
978+
then updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) diags
979+
else forM_ diags $ \d -> liftIO $ logWarning logger $ showDiagnosticsColored [d]
979980
let eq = case (bs, fmap decodeShakeValue old) of
980981
(ShakeResult a, Just (ShakeResult b)) -> a == b
981982
(ShakeStale a, Just (ShakeStale b)) -> a == b

0 commit comments

Comments
 (0)