ApiAnnotations : RdrHsSyn.isFunLhs discards parentheses
authorAlan Zimmerman <alan.zimm@gmail.com>
Thu, 7 May 2015 21:45:44 +0000 (23:45 +0200)
committerAlan Zimmerman <alan.zimm@gmail.com>
Thu, 7 May 2015 21:45:44 +0000 (23:45 +0200)
commit5bde9f7c1834ab4da1fad1838afec1a578c26530
treee014b7efd23380e4d782817a9be818aff2f96475
parentc3e6b3ac50e7cc061825d49d06fb4fc81e6d5bc1
ApiAnnotations : RdrHsSyn.isFunLhs discards parentheses

Summary:
The RdrHsSyn.isFunLhs function has the following

  isFunLhs e = go e []
   where
     go (L loc (HsVar f)) es
          | not (isRdrDataCon f)   = return (Just (L loc f, False, es))
     go (L _ (HsApp f e)) es       = go f (e:es)
     go (L _ (HsPar e))   es@(_:_) = go e es

The treatment of HsPar means that any parentheses around an infix function will be discarded.

e.g.

  (f =*= g) sa i = f (toF sa i) =^= g (toG sa i)

will lose the ( before f and the closing one after g

Test Plan: ./validate

Reviewers: hvr, austin

Reviewed By: austin

Subscribers: bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D832

GHC Trac Issues: #10269
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
testsuite/tests/ghc-api/annotations/.gitignore
testsuite/tests/ghc-api/annotations/Makefile
testsuite/tests/ghc-api/annotations/T10269.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/Test10269.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/all.T
testsuite/tests/ghc-api/annotations/t10269.hs [new file with mode: 0644]