Improve parse error message on indentation mistake
Consider the following code fragment:
(ExecGhc, args) -> execCompiler "" args
-- NOTE: this won't currently work for GHCJS, because it doesn't have
-- a runghcjs binary. It probably will someday, though.
(ExecRunGhc, args) ->
The last line is indented by one space but it is hard to notice esp when we looking at this along with a screenful of code and there are many comments between the two lines. When this code is compiled ghc throws the following error:
Main.hs:745:40: error: parse error on input ‘->’
I look at the error and then the code and wonder what is wrong with this code, there is nothing noticeably wrong. If ghc can provide some context I can easily make out where the problem is. ghc can perhaps tell me how the current expression is being parsed e.g. (ExecRunGhc, args) -> is being considered as a continuation of the expression on the previous line.
I have run into this many times. The first time it was really frustrating.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |