[commit: ghc] master: Add "error:" prefix to error-messages (7febc2b)

git at git.haskell.org git at git.haskell.org
Tue Apr 14 12:33:22 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7febc2bb86b238713cfb9f52dff32039464dfe66/ghc

>---------------------------------------------------------------

commit 7febc2bb86b238713cfb9f52dff32039464dfe66
Author: Konstantine Rybnikov <k-bx at k-bx.com>
Date:   Tue Apr 14 01:38:54 2015 -0500

    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


>---------------------------------------------------------------

7febc2bb86b238713cfb9f52dff32039464dfe66
 compiler/main/ErrUtils.hs                  | 15 +++++++--------
 testsuite/driver/testlib.py                | 12 ++++++++++++
 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 5762a57..d42db57 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 430779b..4e877f5 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 c7eb607..961e1fd 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’



More information about the ghc-commits mailing list