Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Location information of instances is lost if there is aleady a '.hi' #921

Open
@harpocrates

Description

@harpocrates

If there is already a '.hi' file present for a module we are haddock-ing, none of the instances in that module will have any location information.

I initially pointed this out in #906 (comment). I'm making a full blown issue for this because it is turning out to be a bit nastier than I expected.


The third field of DocInstance (the Located (IdP name)) is where we have a disappearing location:

type DocInstance name = (InstHead name, Maybe (MDoc (IdP name)), Located (IdP name), Maybe Module)

This is supposed to glean its location off of dfun_id (or co_ax_name for type families, although that path is not well documented). There is a Note [Haddock assumptions] referenced from that field:

Note [Haddock assumptions]
~~~~~~~~~~~~~~~~~~~~~~~~~~
For normal user-written instances, Haddock relies on

 * the SrcSpan of
 * the Name of
 * the is_dfun of
 * an Instance

being equal to

  * the SrcSpan of
  * the instance head type of
  * the InstDecl used to construct the Instance.

However, when serializing Names in interface files, GHC discards all locations. When reading the interface back out, the location holes get filled with noSrcSpan. All that to say that this note no longer holds if the class instance was read from an interface file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions