[GHC] #11019: ApiAnnotations: Make all RdrName occurences Located
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple ApiAnnotations | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- At the moment the API Annotations can only be used on the `ParsedSource`, as there are changes made to the `RenamedSource` that prevent it from being used to round trip source code. It is possible to build a map from every `Located Name` in the `RenamedSource` from its location to the `Name`, which can then be used when resolved names are required when changing the `ParsedSource`. However, there are instances where the identifier is not located, specifically {{{#!hs (GHC.VarPat name) (GHC.HsVar name) (GHC.UserTyVar name) (GHC.HsTyVar name) }}} Replace each of the `name` types above with `(Located name)` -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Perhaps I'm missing something very simple, but if you have a, for example, `LHsExpr Name` which matches the pattern `(L loc (HsVar name))`, the `loc` should apply just as well to the `name` as to the overall expression. My understanding of each of the cases above is that they all have this property, so adding another `Located` wrapper would be redundant. Or am I missing something? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): It is technically redundant in that with some manipulation the location can be retrieved. But it causes the mapping process to be much more complex than it needs to be when manipulating the AST for source level changes. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): Example code from HaRe to enable changing a name {{{#!hs nameSybTransform :: (Monad m,SYB.Typeable t) => (GHC.Located GHC.RdrName -> m (GHC.Located GHC.RdrName)) -> t -> m t nameSybTransform changer = q where q = SYB.mkM worker `SYB.extM` workerBind `SYB.extM` workerExpr `SYB.extM` workerLIE `SYB.extM` workerHsTyVarBndr `SYB.extM` workerLHsType worker (pnt :: (GHC.Located GHC.RdrName)) = changer pnt workerBind (GHC.L l (GHC.VarPat name)) = do (GHC.L _ n) <- changer (GHC.L l name) return (GHC.L l (GHC.VarPat n)) workerBind x = return x workerExpr ((GHC.L l (GHC.HsVar name))) = do (GHC.L _ n) <- changer (GHC.L l name) return (GHC.L l (GHC.HsVar n)) workerExpr x = return x workerLIE ((GHC.L l (GHC.IEVar (GHC.L ln name))) :: (GHC.LIE GHC.RdrName)) = do (GHC.L _ n) <- changer (GHC.L ln name) return (GHC.L l (GHC.IEVar (GHC.L ln n))) workerLIE x = return x workerHsTyVarBndr (GHC.L l (GHC.UserTyVar name)) = do (GHC.L _ n) <- changer (GHC.L l name) return (GHC.L l (GHC.UserTyVar n)) workerHsTyVarBndr x = return x workerLHsType (GHC.L l (GHC.HsTyVar name)) = do (GHC.L _ n) <- changer (GHC.L l name) return (GHC.L l (GHC.HsTyVar n)) workerLHsType x = return x }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:1512 Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * differential: => Phab:1512 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:1512 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"3df9563e590bbfbfe1bc9171a0e8fc93ceef690d/ghc" 3df9563e/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="3df9563e590bbfbfe1bc9171a0e8fc93ceef690d" ApiAnnotations: Make all RdrName occurences Located At the moment the API Annotations can only be used on the ParsedSource, as there are changes made to the RenamedSource that prevent it from being used to round trip source code. It is possible to build a map from every Located Name in the RenamedSource from its location to the Name, which can then be used when resolved names are required when changing the ParsedSource. However, there are instances where the identifier is not located, specifically (GHC.VarPat name) (GHC.HsVar name) (GHC.UserTyVar name) (GHC.HsTyVar name) Replace each of the name types above with (Located name) Updates the haddock submodule. Test Plan: ./validate Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1512 GHC Trac Issues: #11019 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:1512 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11019: ApiAnnotations: Make all RdrName occurences Located -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: | ApiAnnotations Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:1512 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Alan Zimmerman <alan.zimm@…>): In [changeset:"d8ed20c8772bee5eb83719c804121374157cf9b6/ghc" d8ed20c8/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="d8ed20c8772bee5eb83719c804121374157cf9b6" Add Location to RdrName in FieldOcc Summary: Post #11019, there have been some new instances of RdrName that are not located, in particular ```#!hs data FieldOcc name = FieldOcc { rdrNameFieldOcc :: RdrName , selectorFieldOcc :: PostRn name name } data AmbiguousFieldOcc name = Unambiguous RdrName (PostRn name name) | Ambiguous RdrName (PostTc name name) deriving (Typeable) ``` Add locations to them Updates haddock submodule to match Test Plan: ./validate Reviewers: goldfire, hvr, bgamari, austin Reviewed By: hvr Subscribers: hvr, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1670 GHC Trac Issues: #11258 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11019#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC