lexical-lsp / lexical

Lexical is a next-generation elixir language server
776 stars 77 forks source link

Best-effort go-to-definition if current arity doesn't match #780

Open zachallaun opened 5 days ago

zachallaun commented 5 days ago

I was doing a refactor starting at a call site where I removed an argument to a function, so the call went from e.g. arity 4 to arity 3. If you then try to go-to-definition for that call, it fails because name/3 doesn't exist.

In these cases, I think it would be an improvement to go to the definition that does exist, even if the arity doesn't match.

There's a question of which definition to go to. You could say "closest arity", but if you go-to-definition for name/4 and there's a name/3 and name/5, you still have to somewhat-arbitrarily pick. For simplicity, I'm inclined to go to the lowest-arity existing definition for name. This means that it would go to name/0 if that existed, even though it's probably not what you want, but I think it's the most understandable.