diff options
author | Konstantine Rybnikov <k-bx@k-bx.com> | 2015-04-14 01:38:54 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-04-14 07:33:07 -0500 |
commit | 7febc2bb86b238713cfb9f52dff32039464dfe66 (patch) | |
tree | 7b51542fbb01c3ed5d0327eb62f2dc9792ebea3b | |
parent | a2ce3afaeb5c32556760b9b5185778a4062ba998 (diff) | |
download | haskell-7febc2bb86b238713cfb9f52dff32039464dfe66.tar.gz |
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
-rw-r--r-- | compiler/main/ErrUtils.hs | 15 | ||||
-rw-r--r-- | testsuite/driver/testlib.py | 12 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/ghci/p4.stderr | 7 |
3 files changed, 23 insertions, 11 deletions
diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index 5762a57f3e..d42db57808 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -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 } diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 430779bdc0..4e877f51b6 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -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()]) diff --git a/testsuite/tests/safeHaskell/ghci/p4.stderr b/testsuite/tests/safeHaskell/ghci/p4.stderr index c7eb6070e1..961e1fda8a 100644 --- a/testsuite/tests/safeHaskell/ghci/p4.stderr +++ b/testsuite/tests/safeHaskell/ghci/p4.stderr @@ -1,6 +1,7 @@ -<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’ |