Commit 1c490467 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Store short error message text as a string

We also store the Doc still, although we don't have to; we could
just convert back again, at the cost of some inefficiency.

But we do need the String, so that we can print it in the Show instance.
parent c3a62c56
......@@ -64,7 +64,8 @@ type ErrorMessages = Bag ErrMsg
data ErrMsg = ErrMsg {
errMsgSpans :: [SrcSpan],
errMsgContext :: PrintUnqualified,
errMsgShortDoc :: MsgDoc,
errMsgShortDoc :: MsgDoc, -- errMsgShort* should always
errMsgShortString :: String, -- contain the same text
errMsgExtraInfo :: MsgDoc,
errMsgSeverity :: Severity
}
......@@ -82,7 +83,7 @@ data Severity
| SevFatal
instance Show ErrMsg where
show em = showSDoc (errMsgShortDoc em)
show em = errMsgShortString em
pprMessageBag :: Bag MsgDoc -> SDoc
pprMessageBag msgs = vcat (punctuate blankLine (bagToList msgs))
......@@ -110,7 +111,8 @@ makeIntoWarning err = err { errMsgSeverity = SevWarning }
mk_err_msg :: DynFlags -> Severity -> SrcSpan -> PrintUnqualified -> MsgDoc -> SDoc -> ErrMsg
mk_err_msg _ sev locn print_unqual msg extra
= ErrMsg { errMsgSpans = [locn], errMsgContext = print_unqual
, errMsgShortDoc = msg, errMsgExtraInfo = extra
, errMsgShortDoc = msg , errMsgShortString = showSDoc msg
, errMsgExtraInfo = extra
, errMsgSeverity = sev }
mkLongErrMsg, mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment