Opened 3 years ago

Closed 3 years ago

#10269 closed bug (fixed)

ApiAnnotations : RdrHsSyn.isFunLhs discards parentheses

Reported by: alanz Owned by: alanz
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.10.1
Keywords: ApiAnnotations Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D832
Wiki Page:

Description

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

Change History (5)

comment:1 Changed 3 years ago by alanz

See RdrHsSyn.checkTyClHdr for an example of how to handle this.

comment:2 Changed 3 years ago by alanz

Differential Rev(s): Phab:D832

comment:3 Changed 3 years ago by alanz

Status: newpatch

comment:4 Changed 3 years ago by Alan Zimmerman <alan.zimm@…>

In 5bde9f7c1834ab4da1fad1838afec1a578c26530/ghc:

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

comment:5 Changed 3 years ago by thoughtpolice

Resolution: fixed
Status: patchclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.