Opened 8 years ago

Closed 8 years ago

#3401 closed bug (duplicate)

unintuitive error message about unbalanced parentheses

Reported by: tinlyx Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.3
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


A minimal test case is as follows:

testFunc file = do

let file1 = file) return file1

If you try to load it, you will get: ...\test.hs:111:2:

The last statement in a 'do' construct must be an expression

This error message is kind of unfriendly, and probably only GHC authors know how a mismatched parenthesis can lead to such an error message.

Change History (2)

comment:1 Changed 8 years ago by isaacdupree

I'm not such a GHC author, but it's because the closing-parenthesis terminates the "do" layout (which is a non-error in some cases if there had been an open-parenthesis before the "do" for example). I guess it reports the error in "do"-syntax before getting to the mismatched parenthesis error.

That said, I'd think that GHC ought to be able to look ahead more. Also for the "mismatched parentheses (maybe incorrect indentation?)" error. If parentheses, *regardless* of layout, are still mismatched, then that's definitely an error that could be reported as such :-)

(implementing that might be more adifficult though.)

comment:2 Changed 8 years ago by simonmar

difficulty: Unknown
Resolution: duplicate
Status: newclosed

See #999

Note: See TracTickets for help on using tickets.