-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/cmd/gorename: allow renaming to builtins #22855
Comments
The crash also seems to occur whenever the new name is a builtin name, e.g. |
Actually, In contrast to renaming to builtins which cause crashes, renaming to keywords is handled gracefully:
See /cc @alandonovan |
real
We can improve gorename by handling rename to builtins the same way as keywords are handled. It should return this error: gorename: -to "len": not a valid identifier |
Renames to built-in names should not be handled specially. There are plenty of occasions when you want to re-use a predeclared name, such as a function called print or real, or a method called int or string. The tool should not crash, of course. |
closing as obsoleted by #69360 |
Thanks @seankhliao. Do beware that many of these gorename issues are in principle applicable to gopls' Rename LSP RPC, which runs a fork of the same algorithm. That said, I just verified that this particular issue is fixed in gopls, and that the other ones just closed don't really apply to gopls because it has a notion of a workspace. |
What did you do?
While trying to rename a variable (func, etc..) to
real
the gorename tool panics.Suppose you have a
main.go
like this:And you run
gorename -from 'main.go::world' -to real
What did you expect to see?
Expected output:
Renamed 2 occurrences in 1 file in 1 package.
and the
main.go
file containing:What did you see instead?
System details
The text was updated successfully, but these errors were encountered: