Skip to content

Poor parse error

Given the fragment:

f x = do case x of
            Just foo -> do
                stmt1
                stmt2
                stmt3
                stmt4
                stmt5
                stmt6
            Nothing -> 
                a <- var
                stmt1
                stmt2
                stmt3

There is a parse error after the Nothing, I should have included a do.

GHC says:

bug.hs:1:9: Parse error in pattern

This error message can be made to be arbitrarily far away from the point at which the error actually occurs.

Haskell-src-exts does far better with:

bug.hs:10:19: Parse error in pattern

Reporting <- binding errors against the arrow, rather than the (assumed) start of the pattern seems to be a better choice.

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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