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

find references not working when module not imported #679

Closed
dprophete opened this issue Jan 11, 2022 · 0 comments · Fixed by #953
Closed

find references not working when module not imported #679

dprophete opened this issue Jan 11, 2022 · 0 comments · Fixed by #953
Assignees
Milestone

Comments

@dprophete
Copy link

dprophete commented Jan 11, 2022

I ran into an issue where find references missed a reference.

The simplest repro step involves 3 files:

  • Main.elm: defines alias Person, with field firstName
  • Group.elm: defines alias Group, which contains a Person (so Group.elm import Main.elm)
  • Utils.elm: defines a function which takes a Group and accesses group.person.firstName (Utils.elm only needs to import Group.elm, not Main.elm)

The issue is a find references on firstName misses the usage in Utils.elm. Note that if we import Main.elm in Utils.elm, then it gets detected properly.


Main.elm:

module Main exposing (..)

import Html exposing (Html, span, text)
import Html.Attributes exposing (class)


type alias Person =
    -- doing a 'find references' on firstName here won't detect the fact that it is referenced in Utils.elm
    { firstName : String }


main : Html a
main =
    span [ class "welcome-message" ] [ text "Hello, World!" ]

Group.elm:

module Group exposing (..)

import Main exposing (Person)


type alias Group =
    { person : Person }

Utils.elm:

module Utils exposing (..)

import Group exposing (Group)


{-| the key part is that even though we access group.person.firstname, we never import Person in this file.
As a result, when we try to 'find references' on 'firstName', it doesn't detect the reference in this file.

Note that if you add 'import Main exposing (Person)' then the reference is found

-}
getFirstName : Group -> String
getFirstName group =
    group.person.firstName

my setup:

- latest neovim (compiled a few days ago)
- latest coc.nvim (0.0.80-f6a947a8eb)
- latest elm-language-server (compiled from the main branch on git an hour ago)
- node v14.17.6
- on a M1 mac, running monterey 12.1
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.

2 participants