-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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/gopls: crash in renaming inside packages that use type param composite lits #61614
Comments
Thanks, this is very clearly an oversight in the rename check; I have reproduced based on your minimal example: by reverse engineering, all that is additionally required is to add a method to some time in the package, and rename that method. |
Transferring to the Go issue tracker, since this is a gopls bug. |
Change https://go.dev/cl/513775 mentions this issue: |
I created another issue (#61618) for a related problem that occurs when trying to use the "Go to references" action in VSCode (i.e. cmd/ctrl+clicking on something in most editors) on the generic fields. Also thanks for being responsive and fixing this so quickly! |
gopls version: v0.12.4 (go1.20.3)
gopls flags:
update flags: proxy
extension version: 0.39.1
go version: 1.20.3
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Thu, 27 Jul 2023 03:27:43 GMT
restart history:
Tue, 25 Jul 2023 20:01:41 GMT: activation (enabled: true)
Tue, 25 Jul 2023 20:08:52 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:09:30 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:09:41 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:11:07 GMT: config change (enabled: true)
gopls crashed after trying to refactor/rename a struct field with a generic type.
I don't want to post the exact code that caused this as it's part of a private codebase, but I believe the following is a close enough approximation as far as this issue is concerned:
I tried renaming all of the fields of builder, but only the non generic-typed fields (i.e. name and the other fields) succeeded. Before it crashed, whenever I attempted to rename 'elements' or 'elemData', I just got a notification popup that said "No Result". After a couple times of trying this, gopls eventually just crashed (actually, the logs are showing other identical panics, so it may have crashed the other times too, but it was being restarted until it hit a limit of number of restarts in a certain time period)
edit: I just restarted the language server and tried it again, and while it doesn't crash or panic when trying to rename a generic field, the rename only succeeds in the local scope. So if I try renaming it from the struct's type definition, that's the only place it changes (as if I had just selected it and typed a new name). If I rename it from where it's being used, every use of it in the local scope will change, but everything outside of that scope remains the same.
The text was updated successfully, but these errors were encountered: