Skip to content

Confusing parser error in 8.6

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.

Trac metadata
Trac field Value
Version 8.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Parser)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information