Opened 12 months ago

Last modified 12 months ago

#15705 new bug

Confusing parser error in 8.6

Reported by: diatchki Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler (Parser) Version: 8.6.1
Keywords: BlockArguments Cc: akio
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect error/warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Consider the following example:

f x =
  case x of
    A -> 'a'
   B -> 'b'

The problem here is that B is misaligned, which is quite a common mistake, especially in a bigger case block.

GHC reports the following error:

    Unexpected case expression in function application:
        case x of { A -> 'a' }
    You could write it with parentheses
    Or perhaps you meant to enable BlockArguments?

This is quite confusing, especially since the program won't parse, BlockArguments or not. My guess is that we are being a bit too eager with reporting the BlockArguments issue.

One way to work around this would be to just remember if we used BlockArguments while parsing, but only do the check that the extension is enabled after a successful parse.

Change History (1)

comment:1 Changed 12 months ago by RyanGlScott

Cc: akio added
Keywords: BlockArguments added
Note: See TracTickets for help on using tickets.