
#8607: Invalid location reported for type constructors -------------------------------------+------------------------------------ Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by edsko): So correct me if I'm wrong, but -- `TyCon` contains a `Name`, right? And that `Name` has a `nameSrcSpan`. And that `nameSrcSpan` is what is used for error messages (probably through `setSrcSpan (getSrcSpan thing)` at the start of `checkValidTyCl`?). So `TyCon`s ''already'' have a built-in location, and I guess this was precisely the purpose of Simon's patch. I don't have a problem with the `nameSrcSpan` of a `Name` being set to be the location of the entire type declaration. What ''is'' a problem, however, is that in the AST, that name becomes a `Located Name`, for example as in {{{ data TyClDecl name | -- | @data@ declaration DataDecl { tcdLName :: Located name -- ^ Type constructor ... }}} So `Located Name` has ''two'' `SrcSpan`s; one for the `Located` part, and one for the `Name` part (`nameSrcSpan`). The problem is that Simon's patch changed ''both'' of these `SrcSpan`s to point to the entire span of the type declaration. They are logically different -- one tells you where ''this occurrence'' of the identifier is, the other tells you where the identifier is defined. For IDE purposes we need to know accurate information about the location of this occurrence, even if it's `nameSrcSpan` (def site) points somewhere else. Do I make any sense at all? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8607#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler