[commit: ghc] wip/nomeata-T8466: Change type of `errMsgSpans` field of `ErrMsg` to `SrcSpan` (8e748c6)
git at git.haskell.org
git at git.haskell.org
Wed Oct 23 09:25:38 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nomeata-T8466
Link : http://ghc.haskell.org/trac/ghc/changeset/8e748c66506e228c9d12f63458d026182843c466/ghc
>---------------------------------------------------------------
commit 8e748c66506e228c9d12f63458d026182843c466
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Wed Oct 23 11:24:24 2013 +0200
Change type of `errMsgSpans` field of `ErrMsg` to `SrcSpan`
It was `[SrcSpan]`, but never ever contained more than one span.
>---------------------------------------------------------------
8e748c66506e228c9d12f63458d026182843c466
compiler/main/ErrUtils.lhs | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs
index f9f4387..6957fa0 100644
--- a/compiler/main/ErrUtils.lhs
+++ b/compiler/main/ErrUtils.lhs
@@ -63,7 +63,7 @@ type WarningMessages = Bag WarnMsg
type ErrorMessages = Bag ErrMsg
data ErrMsg = ErrMsg {
- errMsgSpans :: [SrcSpan],
+ errMsgSpans :: SrcSpan,
errMsgContext :: PrintUnqualified,
errMsgShortDoc :: MsgDoc, -- errMsgShort* should always
errMsgShortString :: String, -- contain the same text
@@ -115,7 +115,7 @@ makeIntoWarning err = err { errMsgSeverity = SevWarning }
mk_err_msg :: DynFlags -> Severity -> SrcSpan -> PrintUnqualified -> MsgDoc -> SDoc -> ErrMsg
mk_err_msg dflags sev locn print_unqual msg extra
- = ErrMsg { errMsgSpans = [locn], errMsgContext = print_unqual
+ = ErrMsg { errMsgSpans = locn, errMsgContext = print_unqual
, errMsgShortDoc = msg , errMsgShortString = showSDoc dflags msg
, errMsgExtraInfo = extra
, errMsgSeverity = sev }
@@ -165,29 +165,26 @@ pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc]
pprErrMsgBagWithLoc bag = [ pprLocErrMsg item | item <- sortMsgBag bag ]
pprLocErrMsg :: ErrMsg -> SDoc
-pprLocErrMsg (ErrMsg { errMsgSpans = spans
+pprLocErrMsg (ErrMsg { errMsgSpans = s
, errMsgShortDoc = d
, errMsgExtraInfo = e
, errMsgSeverity = sev
, errMsgContext = unqual })
= sdocWithDynFlags $ \dflags ->
withPprStyle (mkErrStyle dflags unqual) (mkLocMessage sev s (d $$ e))
- where
- (s : _) = spans -- Should be non-empty
printMsgBag :: DynFlags -> Bag ErrMsg -> IO ()
printMsgBag dflags bag
= sequence_ [ let style = mkErrStyle dflags unqual
in log_action dflags dflags sev s style (d $$ e)
- | ErrMsg { errMsgSpans = s:_,
+ | ErrMsg { errMsgSpans = s,
errMsgShortDoc = d,
errMsgSeverity = sev,
errMsgExtraInfo = e,
errMsgContext = unqual } <- sortMsgBag bag ]
sortMsgBag :: Bag ErrMsg -> [ErrMsg]
-sortMsgBag bag = sortBy (comparing (head . errMsgSpans)) $ bagToList bag
- -- TODO: Why "head ."? Why not compare the whole list?
+sortMsgBag bag = sortBy (comparing errMsgSpans) $ bagToList bag
ghcExit :: DynFlags -> Int -> IO ()
ghcExit dflags val
More information about the ghc-commits
mailing list