x/tools/gopls: rename fails with "no object found" when the old identifier is missing a declaration #41851
Labels
Milestone
Comments
Renaming without complete type information will always be somewhat dicey because we can't be certain of the user's intent starting with an invalid program. Renaming an undeclared identifier to a declared name may be an exception, but I'm not sure. Consider this contrived example: func _() {
oldName = "hi"
{
var newName int
{
oldName = "hello"
}
{
oldName = 123
}
} Does it make sense to try to rename any of the oldNames in this case? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version are you using?
Does this issue reproduce with the latest release?
Yes
What did you do?
(https://play.golang.org/p/OSPW1IIzNCs)
emacs
withgopls
viaeglot
, start with a program with an existing undeclared identifier used in several places.(For this example,
errNo
.)errno
).M-x eglot-rename
.What did you expect to see?
References to the (now-undeclared) variable at the point should be renamed so that they now refer to the identifier in step (2).
What did you see instead?
gopls
returns ano object found
error.As reported by
M-x eglot-events-buffer
:The text was updated successfully, but these errors were encountered: