Skip to content

LSP: Crash when aliasing a module #2179

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

Open
spotandjake opened this issue Oct 23, 2024 · 2 comments · May be fixed by #2275
Open

LSP: Crash when aliasing a module #2179

spotandjake opened this issue Oct 23, 2024 · 2 comments · May be fixed by #2275
Labels
bug lsp Issues related to the language server.

Comments

@spotandjake
Copy link
Member

spotandjake commented Oct 23, 2024

The following code causes the lsp to crash with a Not_Found:

from "./host.gr" include Host
use Host.{ module Bindings as A }
print(A.add(1ul, 2ul))

the issue seems to come from aliasing in the module Bindings as A the exception seems to be thrown from Sourcetree when we call find_module, we could fix this by just adding a try catch and not including the item in sourcetree but that just hides the bug and I think this is indicative of a deeper problem. This exception happens when the didOpen event fires.

@spotandjake spotandjake added bug lsp Issues related to the language server. labels Oct 23, 2024
@spotandjake
Copy link
Member Author

After investigating this a little I think the problem here is actually in find_module comparing to find_name if we do not find the given ident in the IdTbl we then check the alias table before declaring it not found this logic does not currently exist in the find_module function.

@spotandjake
Copy link
Member Author

I was digging into this again and noticed that this is actually visible in the compiler with the below code:

The below code causes a NOT_FOUND error because of the use C. where C is an alias:

module Main

module A {
  provide module B {
    provide let b = 1
  }
}
use A.{ module B as C }
use C.{ b }

I'm not sure why this doesn't affect our binding code or resolution elsewhere though, but it indicates things arn't quite as consistent. I think this might be because find_value goes through a completely different code path then find_module, and in the compiler I think we erase aliases when they are used on the module level in other places.

@spotandjake spotandjake linked a pull request Apr 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug lsp Issues related to the language server.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant