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

LSP suggests unavailable methods #6608

Closed
nventuro opened this issue Nov 22, 2024 · 0 comments · Fixed by #6617
Closed

LSP suggests unavailable methods #6608

nventuro opened this issue Nov 22, 2024 · 0 comments · Fixed by #6617
Assignees
Labels
bug Something isn't working

Comments

@nventuro
Copy link
Contributor

nventuro commented Nov 22, 2024

Aim

Given a struct with some impls, the LSP suggests autocompletion with fns that are not available in the current context.

Expected Behavior

Consider the following program

struct Foo<T> {
    t: T,
}

impl Foo<Field> {
    fn bar(_self: Self) -> Field {
        5
    }
}

impl Foo<u32> {
    fn bar(_self: Self) -> Field {
        5
    }

    fn baz(_self: Self) -> Field {
        6
    }
}

fn main() -> pub Field {
    let foo: Foo<Field> = Foo { t: 5 };
    foo.bar()
}

In the last line, only bar() can be called on foo.

Bug

The LSP suggests incorrect autocompletes:

Image

Note that two versions of bar are suggested, one for each impl. However, the second one cannot be called since I have Foo<Field> and not Foo<u32>.

baz is also suggested as an alternative, but this is invalid: that method is not available on the type since it belongs to the other specialization.

Finally, t is suggested even though it is not public (and currently results in a warning).

@nventuro nventuro added the bug Something isn't working label Nov 22, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 22, 2024
@asterite asterite self-assigned this Nov 25, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Nov 26, 2024
@nventuro nventuro changed the title LSP suggest unavailable methods LSP suggests unavailable methods Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants