diff options
author | Ian Lynagh <igloo@earth.li> | 2012-06-12 15:47:40 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-06-12 15:47:40 +0100 |
commit | 1c490467fce17d97c30bc518df498f9b353d10d6 (patch) | |
tree | 59f7c0c1b8c201254f91543714d0816652884c56 /compiler | |
parent | c3a62c563fb62d4d8b94c0dc0c270724b35d4341 (diff) | |
download | haskell-1c490467fce17d97c30bc518df498f9b353d10d6.tar.gz |
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.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/main/ErrUtils.lhs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs index dafc7e61aa..83f57c3888 100644 --- a/compiler/main/ErrUtils.lhs +++ b/compiler/main/ErrUtils.lhs @@ -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 |