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

GHC ghc-devs at haskell.org
Wed Jan 28 14:15:47 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:
-------------------------------------+-------------------------------------
Changes (by spl):

 * cc: sean.leather@… (added)


Old description:

> The proposal is to modify GHC compile-time output for error-messages, by
> adding a prefix, similar to what we currently have for warnings.
>
> 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 current output for an error:
>
> {{{
> ➜ 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 it 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 proposal only affects error messages produced by GHC itself.  For
> example, the behaviour of the `error` function is unaffected.
>
> == Motivation ==
>
> Main motivation point right now is that there's a ticket #9219 (parallel
> build's output of errors doesn't occur at the end of output), due to
> which, error-reporting of your program might get lost somewhere in the
> middle of a build-log. As another example, if your program has a lot of
> warnings, and you build it with multiple cores, you almost always get an
> error lost somewhere in the middle of warnings and it's almost impossible
> to find.
>
> So, this feature's main purpose is to ease navigation in textual output
> of ghc in order to find errors quickly, not being tied to output
> ordering.
>
> == Disadvantages ==
>
> Many regression tests might need a fix.
>
> == 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 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.

--

Comment:

 I modified the ticket description in an attempt to be more clear about the
 proposal and to expand the motivation.

 P.S. I'm heavily in favor of this.

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


More information about the ghc-tickets mailing list