Misattributed parse error in do block
|Reported by:||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
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.