Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

implementations: "this function is not a method" error could just simply be "no results" #307

Open
slimsag opened this issue Aug 15, 2018 · 5 comments

Comments

@slimsag
Copy link
Member

slimsag commented Aug 15, 2018

If you find implementations on a function rather than a method, you get an error:

Error getting implementations: This function is not a method

e.g. https://sourcegraph.com/github.com/sourcegraph/go-langserver/-/blob/langserver/implementation.go#L65:6&tab=impl

Of course, finding implementations on a function doesn't make sense. It only works on interface types and methods (finding the interfaces that implement that method).

We could make this error less confusing by e.g. just returning no error and simply returning no results.

The error originates from here: https://sourcegraph.com/github.com/sourcegraph/go-langserver@bf90fac03a4d1a07f50701547d56fabfdb0c32ec/-/blob/langserver/implementation.go#L76:30

@berkant
Copy link
Contributor

berkant commented Aug 17, 2018

IMHO, present error is better as it is a no-go for a function or method to be implemented. I also wonder how come it would work on methods. Sounds illogical to me.

@nicksnyder
Copy link
Contributor

The language server client (e.g. editors) shouldn't need to know a priori if a given location in a file is a valid location to call "find implementations". No results instead of an error makes sense to me.

@kevinburke
Copy link

I'm not sure that that's right FWIW, or it might be masking an error.

Calling "find implementations" on MustParse in github.com/kevinburke/aws-vault/vendor/github.com/alecthomas/kingpin.v2 should return at least one implementation, in github.com/kevinburke/aws-vault/main.go, but it doesn't find it.

local URL is http://localhost:7080/github.com/kevinburke/aws-vault/-/blob/vendor/gopkg.in/alecthomas/kingpin.v2/global.go#L84:6&tab=impl

@keegancsmith
Copy link
Member

@kevinburke Find implementations finds methods which implement an interface methods. What you are referring to is find references. In this case it works https://sourcegraph.com/github.com/kevinburke/aws-vault/-/blob/vendor/gopkg.in/alecthomas/kingpin.v2/global.go#L84:6=&tab=references

@kevinburke
Copy link

I suppose but I guess even if I'm calling it incorrectly, it would be nice if the error message was clearer, for example, it could say "this function is not an interface definition" instead of "this function is not a method", the latter of which doesn't make much sense.

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

No branches or pull requests

5 participants