Misattributed parse error in do block
In the following program, there is clearly an extra closing parenthesis. However, the error message doesn't point to the actual problem:
main = do x <- 1)
return ()
-- test.hs:1:10: The last statement in a 'do' construct must be an expression
The reported error is at the beginning of the statement "x <- 1
", not at the closing parenthesis. When this first happened to me, I spent a lot of time puzzling over the beginning of the statement and the indentation of various lines before I discovered the real problem.
In this example, the error could be attributed to that unmatched parenthesis. Since 'do' blocks can legitimately be enclosed in parentheses, it might be more usable if the error message could identify the locations of both the statement and the end of the 'do' block -- this would point out both potential problem locations.
Trac metadata
Trac field | Value |
---|---|
Version | 6.4.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Parser) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |