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

Module attribute falsely flagged as 'Unresolved module attribute' #1767

Closed
rengel-de opened this issue Apr 28, 2020 · 2 comments · Fixed by #1781
Closed

Module attribute falsely flagged as 'Unresolved module attribute' #1767

rengel-de opened this issue Apr 28, 2020 · 2 comments · Fixed by #1781

Comments

@rengel-de
Copy link

rengel-de commented Apr 28, 2020

defmodule Calixir.Calendar.Hebrew do
  @nisan 1
  @iyyar 2
  @Sivan 3
  @tammuz 4
  @av 5
  @elul 6
  @tishri 7
  @marheshvan 8
  @kislev 9
  @tevet 10
  @shevat 11
  @adar 12 # This one creates an error.
  @adarii 13

  def nisan, do: @nisan
  def iyyar, do: @iyyar
  def sivan, do: @Sivan
  def tammuz, do: @tammuz
  def av, do: @av
  def elul, do: @elul
  def tishri, do: @tishri
  def marheshvan, do: @marheshvan
  def kislev, do: @kislev
  def tevet, do: @tevet
  def shevat, do: @shevat
  def adar, do: @adar  # Falsely flagged as 'Unresolved module attibute'.
  def adarii, do: @adarii
end

If two module attributes start with the same letters (like @adar and @adarii in the code above), then later in the code, the shorter one is falsely flagged as an 'Unresolved module attribute'.

@KronicDeth
Copy link
Owner

It is probably due to when I relaxed the references implementation to support Go To Definition and Show Info when typing and it broke an assumption in the module attribute annotator because it assumes there must be exactly one resolution instead of checking that there is 1 valid match. (Partial matches aren't marked as valid.)

@KronicDeth KronicDeth added this to the 11.6.2 milestone May 22, 2020
KronicDeth added a commit that referenced this issue May 23, 2020
…alid

Fixes #1767

Previously, it was checked if module attributes resolved to exactly one declaration, but this is no longer true with the looser reference resolution that allows invalid results for PisPolyVariantReference.  `resolve()` will return `null` when there is more than one result from `multiResolve` even if some are invalid, so we need to explicitly check if the `PsiReference` is a `PsiPolyVariantReference` and if so check if any are valid.
@rengel-de
Copy link
Author

Thanks! Problem is gone.

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

Successfully merging a pull request may close this issue.

2 participants