Skip to content

unhelpful parse error message: Unexpected do block in function application

Not a bug, as ghc correctly rejects an invalid program. But I have the impression that the error message is getting less precise (for reason and location) from 8.4 to 8.6:

foo = do
  let x = case y of
    Nothing -> True
  bar
  1. 6.3 says
P.hs:1:7: error:
    Unexpected do block in function application:
        do let x = ...
    You could write it with parentheses
    Or perhaps you meant to enable BlockArguments?
  |
1 | foo = do
  |       ^^...

I am not seeing what application ghc thinks of.

  1. 4.4 had the more useful
P.hs:3:5: error: parse error on input ‘Nothing’
  |
3 |     Nothing -> True
  |     ^^^^^^^

More useful, since in the actual code, from which I distilled the above, there were a dozen lines between the locations that were reported by 8.6.3 and 8.4.4.

Trac metadata
Trac field Value
Version 8.6.3
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