-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 a type is not allowed when it has the same name as a parameter #66150
Comments
My first thought was that this bug was fixed by https://go.dev/cl/544035 since I can't reproduce it at master... but I can't reproduce it at v0.14.2 either:
I'll keep investigating... |
What you are describing is definitely a bug--the renaming should succeed--but unfortunately I can't reproduce this at all using v0.14.2 or v0.15.1; using the function or the method; or renaming the parameter's type to match the name, or vice versa. |
Well, it's good to know that it's definitely a bug and that there aren't any weird corner cases of the language that would make the renaming unsound. I enabled the
Doesn't seem like there's any new information there, though. |
@adonovan I wrote test cases on the master branch to replicate the issue. |
Change https://go.dev/cl/581277 mentions this issue: |
Can you confirm that this problem still exists in a gopls built with go1.22 or later? I think this is likely a duplicate of #60752 which was fixed in go1.22. |
This appears to be fixed now, using gopls v0.15.2. I don't know if that was built with go1.22 or not. Versions of other related tools:
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/codespace/.cache/go-build'
GOENV='/home/codespace/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4182857365=/tmp/go-build -gno-record-gcc-switches' |
I built gopls with go1.22.2 and it works. |
Closing as dup of #60752. |
gopls version
golang.org/x/tools/gopls v0.14.2
go env
What did you do?
Attempted to rename a struct type to a new name that was the same as existing parameter names, using VSCode's "Rename Symbol" action.
I attempted to rename
myData
todata
.https://github.com/DylanSp/gopls-rename-issue-repro/blob/main/main.go demonstrates the issue; it also happens with method receivers.
What did you see happen?
The following error message:
What did you expect to see?
The
myData
type to be renamed todata
. I think this should always be valid, but I'm not 100% positive; if I manually renamemyData
todata
in the example code, it compiles.Editor and settings
VSCode version 1.87.0.
VSCode Go extension v0.41.1.
Logs
The text was updated successfully, but these errors were encountered: