Skip to content

SrcSpan incorrect for non-alphanumeric VarPat

There is an inconsistency when parsing patterns which contain non-alphanumeric characters.

For example,

foo (.) = 5

the pattern parses as the following.

 (L {tests/examples/ArgPuncParens.hs:2:5-7}
   (VarPat
    (Unqual {OccName: .})))]

Then consider the following similar program.

foo (x) = 5

The parse is as follows.

  (L {tests/examples/ArgPuncParens.hs:2:5-7}
    (ParPat
      (L {tests/examples/ArgPuncParens.hs:2:6}
        (VarPat
          (Unqual {OccName: x})))))]

Notice two differences.

  1. The first parse lacks a surrounding ParPat.
  2. If the ParPat is deliberately omitted then the given location encompasses the surrounding parentheses which is not consistent with the second example where VarPat specifically refers to x.
Edited by Matthew Pickering
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information