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 ...@@ -64,7 +64,8 @@ type ErrorMessages = Bag ErrMsg
data ErrMsg = ErrMsg { data ErrMsg = ErrMsg {
errMsgSpans :: [SrcSpan], errMsgSpans :: [SrcSpan],
errMsgContext :: PrintUnqualified, errMsgContext :: PrintUnqualified,
errMsgShortDoc :: MsgDoc, errMsgShortDoc :: MsgDoc, -- errMsgShort* should always
errMsgShortString :: String, -- contain the same text
errMsgExtraInfo :: MsgDoc, errMsgExtraInfo :: MsgDoc,
errMsgSeverity :: Severity errMsgSeverity :: Severity
} }
...@@ -82,7 +83,7 @@ data Severity ...@@ -82,7 +83,7 @@ data Severity
| SevFatal | SevFatal
instance Show ErrMsg where instance Show ErrMsg where
show em = showSDoc (errMsgShortDoc em) show em = errMsgShortString em
pprMessageBag :: Bag MsgDoc -> SDoc pprMessageBag :: Bag MsgDoc -> SDoc
pprMessageBag msgs = vcat (punctuate blankLine (bagToList msgs)) pprMessageBag msgs = vcat (punctuate blankLine (bagToList msgs))
...@@ -110,7 +111,8 @@ makeIntoWarning err = err { errMsgSeverity = SevWarning } ...@@ -110,7 +111,8 @@ makeIntoWarning err = err { errMsgSeverity = SevWarning }
mk_err_msg :: DynFlags -> Severity -> SrcSpan -> PrintUnqualified -> MsgDoc -> SDoc -> ErrMsg mk_err_msg :: DynFlags -> Severity -> SrcSpan -> PrintUnqualified -> MsgDoc -> SDoc -> ErrMsg
mk_err_msg _ sev locn print_unqual msg extra mk_err_msg _ sev locn print_unqual msg extra
= ErrMsg { errMsgSpans = [locn], errMsgContext = print_unqual = ErrMsg { errMsgSpans = [locn], errMsgContext = print_unqual
, errMsgShortDoc = msg, errMsgExtraInfo = extra , errMsgShortDoc = msg , errMsgShortString = showSDoc msg
, errMsgExtraInfo = extra
, errMsgSeverity = sev } , errMsgSeverity = sev }
mkLongErrMsg, mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg mkLongErrMsg, mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg
......
Supports Markdown
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