Opened 6 years ago

Closed 6 years ago

#5057 closed feature request (duplicate)

poor parser error message

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


Here's the error message:

    parse error (possibly incorrect indentation)

Here's the last few lines of the file:

    condition (foo "thing" <= bar (fromIntegral (a + b))
            && foo "other" > bar (fromIntegral(a - b))
	       (baz 1) (baz 0)

-- this is line 52, the apparent location of the error

Can you guess what the error is? Yes, of course we can, because we've seen this bad error message enough times to know that it really means

    unterminated '('

This error confuses new and casual users. It directs them away from the location of the error and provides a hint "possibly incorrect indentation" that will also send them in the wrong direction.

Probably this message, and the parse error messages generally are not good because of limitations of happy. happy does not provide much to help construct error messages except the state of the parser at the time. The frown parser generator provides slightly more info, it provides the parse error function with the set of tokens that were expected at that point. If happy were extended in that way, that might be just enough to produce a better error since we could see that ')' was in the set of expected tokens.

Change History (2)

comment:1 Changed 6 years ago by simonmar

We're collecting these in #459. I agree we need to do better, but you're right that Happy doesn't make this easy. Frown doesn't seem to exist any more (it's not on Hackage, and its web page has disappeared).

comment:2 Changed 6 years ago by simonmar

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.