diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-02-16 03:38:21 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-02-16 13:32:03 +0300 |
commit | 60eb2fba1d31ca3bb1dea34c019c42db5340cb44 (patch) | |
tree | eaf29330ee272a90b7f2ed9a8eb4dbf1284e9a17 /compiler/main/ErrUtils.hs | |
parent | 5544f6082d6e15d305b83f27f4daa29576d3666e (diff) | |
download | haskell-wip/parse-errors.tar.gz |
Fix warnings and fatal parsing errorswip/parse-errors
Diffstat (limited to 'compiler/main/ErrUtils.hs')
-rw-r--r-- | compiler/main/ErrUtils.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index ac97f173f2..9ee6856275 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -22,6 +22,7 @@ module ErrUtils ( errMsgSpan, errMsgContext, errorsFound, isEmptyMessages, isWarnMsgFatal, + warningsToMessages, -- ** Formatting pprMessageBag, pprErrMsgBagWithLoc, @@ -359,6 +360,15 @@ isEmptyMessages (warns, errs) = isEmptyBag warns && isEmptyBag errs errorsFound :: DynFlags -> Messages -> Bool errorsFound _dflags (_warns, errs) = not (isEmptyBag errs) +warningsToMessages :: DynFlags -> WarningMessages -> Messages +warningsToMessages dflags = + partitionBagWith $ \warn -> + case isWarnMsgFatal dflags warn of + Nothing -> Left warn + Just err_reason -> + Right warn{ errMsgSeverity = SevError + , errMsgReason = ErrReason err_reason } + printBagOfErrors :: DynFlags -> Bag ErrMsg -> IO () printBagOfErrors dflags bag_of_errors = sequence_ [ let style = mkErrStyle dflags unqual |