Add "Error:" prefix for compile-time error messages
We propose adding the prefix Error:
to compile-time error messages produced by GHC.
An example of a warning message (see Warning:
prefix):
➜ cat test.hs
main = putStrLn "Hello!"
➜ ghc --make -fforce-recomp -Wall ./test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
test.hs:1:1: Warning:
Top-level binding with no type signature: main :: IO ()
Linking test ...
An example of a current error message:
➜ cat test2.hs
main = foo
➜ ghc --make -fforce-recomp -Wall ./test2.hs
[1 of 1] Compiling Main ( test2.hs, test2.o )
test2.hs:1:8: Not in scope: ‘foo’
The proposal is to change the error message to become:
➜ cat test2.hs
main = foo
➜ ghc --make -fforce-recomp -Wall ./test2.hs
[1 of 1] Compiling Main ( test2.hs, test2.o )
test2.hs:1:8: Error: Not in scope: ‘foo’
This change affects only the error messages produced by GHC when compiling. It does not change runtime error reporting, e.g. with the error
function.
Motivation
We wish to make compile-time error messages easier for humans and computers to identify. For example, when running a long parallel build, it can be easy to miss an error message (see #9219 for an example). With a known string such as Error:
, we can use search functionality in a terminal window or text editor (when viewing the build log) or use a command-line tool such as grep
(when streaming and filtering the build log) to quickly find errors.
As a secondary motivation, adding Error:
for error messages brings a nice symmetry to the current use of Warning:
for warning messages.
Disadvantages
The output of many regression tests will need to be updated for the new error message format.
Additional consideration
@hvr [ticket:10021#comment:95657 suggested] that during work on this bug we could make GHC output more consistent with other compilers (GCC and clang) by using lowercase error:
and warning:
prefixes. This might be potentially useful for existing tools that work on top of compiler output for finding errors/warning, and GHC's output will become "more valid" for them.