Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record constructors being given as references to the fields with GHC versions >= 9 #45

Open
OliverMadine opened this issue Jul 6, 2022 · 3 comments · May be fixed by #73
Open

Record constructors being given as references to the fields with GHC versions >= 9 #45

OliverMadine opened this issue Jul 6, 2022 · 3 comments · May be fixed by #73

Comments

@OliverMadine
Copy link

Example

newtype Foo = Foo { field :: Int }

When querying for the point-refs at line 1 column 22 (i.e. on the field name), the Foo constructor is given as a reference.

Version

This seems to only be an issue with GHC versions >= 9

This is causing haskell-language-server/#2915.

@michaelpj
Copy link

Nag @wz1000 ?

@deemp
Copy link

deemp commented May 22, 2023

Hi, @wz1000! Any news on that?

@jhrcek
Copy link
Collaborator

jhrcek commented Feb 18, 2024

I looked into where these duplicate references to data constructors are coming from and here's what I found:

For this example module

module A where
data Foo = Bar { a :: !Int , b :: !Int }

We end up with the following in the refmap here

 (Right Bar,
  [ (A.hs:2:12-14, Details:  Nothing {declaration of constructor bound at: A.hs:2:12-40})
  , (A.hs:2:18, Details:  Nothing {usage}) -- corresponds to src span of "a" field
  , (A.hs:2:30, Details:  Nothing {usage}) -- corresponds to src span of "b" field
  ])

This flat function "flattens" this info into

[ (Right Bar, (A.hs:2:12-14, Details:  Nothing {declaration of constructor bound at: A.hs:2:12-40}))
, (Right Bar, (A.hs:2:18, Details:  Nothing {usage}))
, (Right Bar, (A.hs:2:30, Details:  Nothing {usage}))
]

and we end up with 3 references to Bar constructor, although just one of the 3 identifierDetails in the RefMap was actual reference to the Bar constructor:

image

@wz1000 I could use some hints on how to proceed.
Is it
a) a bug in how ghc generates a ref map, including IdentifierDetails under Bar constructors that shouldn't be there?
b) a bug in indexing code - which should filter out the constructor fields and only index actual reference to the Bar constructor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants