[GHC] #10021: Add "Error:" prefix for compile-time error messages

GHC ghc-devs at haskell.org
Wed Jan 28 14:19:03 UTC 2015


#10021: Add "Error:" prefix for compile-time error messages
-------------------------------------+-------------------------------------
        Reporter:  k-bx              |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:  7.12.1
       Component:  Compiler          |                 Version:  7.8.4
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Description changed by spl:

Old description:

> 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 proposed that during work on this bug we could make GHC output more
> consistent with other compiler's (GCC and clang) by also lower-casing
> "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.

New description:

 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 [comment:5 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.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10021#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list