Commit 7febc2bb authored by Konstantine Rybnikov's avatar Konstantine Rybnikov Committed by Austin Seipp

Add "error:" prefix to error-messages

Add "error:" prefix to error-messages, also lowercase "Warning:"
message to match GCC behavior closer.

Reviewed By: thomie, austin

Differential Revision: https://phabricator.haskell.org/D811

GHC Trac Issues: #10021
parent a2ce3afa
......@@ -111,10 +111,6 @@ data Severity
| SevError
| SevFatal
isWarning :: Severity -> Bool
isWarning SevWarning = True
isWarning _ = False
instance Show ErrMsg where
show em = errMsgShortString em
......@@ -132,10 +128,13 @@ mkLocMessage severity locn msg
else ppr (srcSpanStart locn)
in hang (locn' <> colon <+> sev_info) 4 msg
where
sev_info = ppWhen (isWarning severity)
(ptext (sLit "Warning:"))
-- For warnings, print Foo.hs:34: Warning:
-- <the warning message>
-- Add prefixes, like Foo.hs:34: warning:
-- <the warning message>
sev_info = case severity of
SevWarning -> ptext (sLit "warning:")
SevError -> ptext (sLit "error:")
SevFatal -> ptext (sLit "fatal:")
_ -> empty
makeIntoWarning :: ErrMsg -> ErrMsg
makeIntoWarning err = err { errMsgSeverity = SevWarning }
......
......@@ -1689,6 +1689,11 @@ def normalise_whitespace( str ):
return str
def normalise_errmsg( str ):
# remove " error:" and lower-case " Warning:" to make patch for
# trac issue #10021 smaller
str = modify_lines(str, lambda l: re.sub(' error:', '', l))
str = modify_lines(str, lambda l: re.sub(' Warning:', ' warning:', l))
# If somefile ends in ".exe" or ".exe:", zap ".exe" (for Windows)
# the colon is there because it appears in error messages; this
# hacky solution is used in place of more sophisticated filename
......@@ -1744,6 +1749,10 @@ def normalise_exe_( str ):
return str
def normalise_output( str ):
# remove " error:" and lower-case " Warning:" to make patch for
# trac issue #10021 smaller
str = modify_lines(str, lambda l: re.sub(' error:', '', l))
str = modify_lines(str, lambda l: re.sub(' Warning:', ' warning:', l))
# Remove a .exe extension (for Windows)
# This can occur in error messages generated by the program.
str = re.sub('([^\\s])\\.exe', '\\1', str)
......@@ -2291,3 +2300,6 @@ def getStdout(cmd_and_args):
return stdout
else:
raise Exception("Need subprocess to get stdout, but don't have it")
def modify_lines(s, f):
return '\n'.join([f(l) for l in s.splitlines()])
<interactive>:6:9: Not in scope: ‘System.IO.Unsafe.unsafePerformIO’
<interactive>:6:9: error:
Not in scope: ‘System.IO.Unsafe.unsafePerformIO’
<interactive>:7:9: Not in scope: ‘x’
<interactive>:7:9: error: Not in scope: ‘x’
<interactive>:8:1: Not in scope: ‘y’
<interactive>:8:1: error: Not in scope: ‘y’
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