Skip to content

Commit 25bfcb3

Browse files
committed
Use CPP to prevent setting _code before structured errors
1 parent a46f0a2 commit 25bfcb3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ghcide/src/Development/IDE/Types/Diagnostics.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ ideErrorFromLspDiag lspDiag fdFilePath origMsg =
7272
Nothing -> NoStructuredMessage
7373
Just msg -> SomeStructuredMessage msg
7474
fdLspDiagnostic = lspDiag
75+
#if MIN_VERSION_ghc(9,6,1)
7576
{ _code = fmap ghcCodeToLspCode . diagnosticCode . errMsgDiagnostic =<< origMsg
7677
}
78+
#endif
79+
#if MIN_VERSION_ghc(9,8,1)
7780
ghcCodeToLspCode :: DiagnosticCode -> Int32 LSP.|? T.Text
78-
#if MIN_VERSION_ghc(9,10,1)
7981
ghcCodeToLspCode = InR . T.pack . show
80-
#else
82+
#elif MIN_VERSION_ghc(9,6,1)
83+
-- DiagnosticCode only got a show instance in 9.8.1
84+
ghcCodeToLspCode :: DiagnosticCode -> Int32 LSP.|? T.Text
8185
ghcCodeToLspCode (DiagnosticCode prefix c) = InR $ T.pack $ prefix ++ "-" ++ printf "%05d" c
8286
#endif
8387
in

0 commit comments

Comments
 (0)