@@ -1075,11 +1075,7 @@ parseHeader dflags filename contents = do
1075
1075
let loc = mkRealSrcLoc (Util. mkFastString filename) 1 1
1076
1076
case unP Compat. parseHeader (initParserState (initParserOpts dflags) contents loc) of
1077
1077
PFailedWithErrorMessages msgs ->
1078
- #if MIN_VERSION_ghc(9,5,0)
1079
- throwE $ diagFromErrMsgs sourceParser dflags $ msgs dflags
1080
- #else
1081
- throwE $ diagFromSDocErrMsgs sourceParser dflags $ msgs dflags
1082
- #endif
1078
+ throwE $ diagFromGhcErrorMessages sourceParser dflags $ msgs dflags
1083
1079
POk pst rdr_module -> do
1084
1080
let (warns, errs) = renderMessages $ getPsMessages pst
1085
1081
@@ -1093,17 +1089,9 @@ parseHeader dflags filename contents = do
1093
1089
-- errors are those from which a parse tree just can't
1094
1090
-- be produced.
1095
1091
unless (null errs) $
1096
- #if MIN_VERSION_ghc(9,5,0)
1097
- throwE $ diagFromErrMsgs sourceParser dflags errs
1098
- #else
1099
- throwE $ diagFromSDocErrMsgs sourceParser dflags errs
1100
- #endif
1092
+ throwE $ diagFromGhcErrorMessages sourceParser dflags errs
1101
1093
1102
- #if MIN_VERSION_ghc(9,5,0)
1103
- let warnings = diagFromErrMsgs sourceParser dflags warns
1104
- #else
1105
- let warnings = diagFromSDocErrMsgs sourceParser dflags warns
1106
- #endif
1094
+ let warnings = diagFromGhcErrorMessages sourceParser dflags warns
1107
1095
return (warnings, rdr_module)
1108
1096
1109
1097
-- | Given a buffer, flags, and file path, produce a
@@ -1121,11 +1109,7 @@ parseFileContents env customPreprocessor filename ms = do
1121
1109
contents = fromJust $ ms_hspp_buf ms
1122
1110
case unP Compat. parseModule (initParserState (initParserOpts dflags) contents loc) of
1123
1111
PFailedWithErrorMessages msgs ->
1124
- #if MIN_VERSION_ghc(9,5,0)
1125
- throwE $ diagFromErrMsgs sourceParser dflags $ msgs dflags
1126
- #else
1127
- throwE $ diagFromSDocErrMsgs sourceParser dflags $ msgs dflags
1128
- #endif
1112
+ throwE $ diagFromGhcErrorMessages sourceParser dflags $ msgs dflags
1129
1113
POk pst rdr_module ->
1130
1114
let
1131
1115
psMessages = getPsMessages pst
@@ -1159,12 +1143,7 @@ parseFileContents env customPreprocessor filename ms = do
1159
1143
-- errors are those from which a parse tree just can't
1160
1144
-- be produced.
1161
1145
unless (null errors) $
1162
- #if MIN_VERSION_ghc(9,5,0)
1163
- throwE $ diagFromErrMsgs sourceParser dflags errors
1164
- #else
1165
- throwE $ diagFromSDocErrMsgs sourceParser dflags errors
1166
- #endif
1167
-
1146
+ throwE $ diagFromGhcErrorMessages sourceParser dflags errors
1168
1147
1169
1148
-- To get the list of extra source files, we take the list
1170
1149
-- that the parser gave us,
@@ -1194,11 +1173,7 @@ parseFileContents env customPreprocessor filename ms = do
1194
1173
srcs2 <- liftIO $ filterM doesFileExist srcs1
1195
1174
1196
1175
let pm = ParsedModule ms parsed' srcs2
1197
- #if MIN_VERSION_ghc(9,5,0)
1198
- warnings = diagFromErrMsgs sourceParser dflags warns
1199
- #else
1200
- warnings = diagFromSDocErrMsgs sourceParser dflags warns
1201
- #endif
1176
+ warnings = diagFromGhcErrorMessages sourceParser dflags warns
1202
1177
pure (warnings ++ preproc_warning_file_diagnostics, pm)
1203
1178
1204
1179
loadHieFile :: Compat. NameCacheUpdater -> FilePath -> IO GHC. HieFile
0 commit comments