Misattributed parse error in do block
|Reported by:||red5_2@…||Owned by:|
|Type of failure:||None/Unknown||Difficulty:||Moderate (less than a day)|
|Test Case:||Blocked By:|
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.
Change History (8)
comment:1 Changed 7 years ago by simonmar
- Difficulty changed from Unknown to Moderate (1 day)
- Milestone set to _|_
comment:7 Changed 4 years ago by simonmar
- Difficulty changed from Moderate (1 day) to Moderate (less than a day)