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: renaming mishandles embedded fields #43616
Comments
Change https://golang.org/cl/282932 mentions this issue: |
Thanks for reporting. It looks like we just missed this case. |
@findleyr Thanks for the quick fix. QQ: In the test case, it looks like it's testing renaming at the type declaration. Will the same fix also work for renaming at selector expressions (e.g., L7)? |
Err, no, that doesn't work. My bad for missing that. We need to update the corresponding logic to find the object being renamed. |
Upon a bit more consideration, I'm not sure this feature is perfectly symmetric. When renaming the type name it makes sense that we should also update uses of embeddings of that type. But it's not so clear that the reverse should hold. If I am positioned on x.foo and perform the renaming, it could be surprising that this results in the foo type being renamed. Perhaps we should disallow renaming embedded fields: the user should either rename the type OR give the field a name... |
Yeah, I agree reporting an error instead of also renaming the type makes sense. |
Change https://golang.org/cl/284312 mentions this issue: |
I'd expect that if I try to use gopls to rename any of the
foo
identifiers tobar
in the package below, then all 3 should change. However, gopls only updates 2 of them, resulting in an invalid source file.I'm using gopls v0.6.2.
/cc @stamblerre @findleyr
The text was updated successfully, but these errors were encountered: