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

suggest: try to find the implementation of a symbol when def is used #15555

Merged
merged 2 commits into from
Oct 14, 2020

Conversation

alaviss
Copy link
Collaborator

@alaviss alaviss commented Oct 12, 2020

Fixes nim-lang/nimsuggest#79.

Known issues:
- The forward declaration of the symbol is now inaccessible.

compiler/suggest.nim Outdated Show resolved Hide resolved
alaviss added a commit to alaviss/nim.nvim that referenced this pull request Oct 12, 2020
When there are multiple declarations of a symbol, nim.nvim will now
create a location list with both the forward declaration and the
implementation. The plugin will then jumps to the implementation.

Implemented to handle nim-lang/Nim#15555. Should not affect older
versions of nimsuggest.
@Araq Araq merged commit c2ba4ef into nim-lang:devel Oct 14, 2020
@alaviss alaviss deleted the fix-def-forward branch October 15, 2020 03:58
@RSDuck
Copy link
Contributor

RSDuck commented Nov 5, 2020

is it intentional that both declarations are only returned when the location from which the definition is asked from is before the definition?

proc test(): int

proc test(): int = discard

discard test() # def from here only returns the body

RSDuck added a commit to RSDuck/vscode-nim-1 that referenced this pull request Nov 5, 2020
saem pushed a commit to saem/vscode-nim that referenced this pull request Nov 6, 2020
Allow for multiple definitions to be returned
see nim-lang/Nim#15555
@alaviss
Copy link
Collaborator Author

alaviss commented Nov 6, 2020

@RSDuck

Yea, it's a small quirk in the way nimsuggest perform its analysis. To make it work we would need to rethink how nimsuggest functions, and I'm not up for that atm :P

mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
…im-lang#15555)

* suggest: try to find the implementation of a symbol when def is used

* suggest: return all declarations of the symbol on `def`
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 this pull request may close these issues.

def should go to definition, not forward declaration
4 participants