You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
gopherbot
added
Tools
This label describes issues relating to any tools in the x/tools repository.
gopls
Issues related to the Go language server, gopls.
labels
Jul 21, 2023
Thanks for the bug report. I can reproduce it using the testcase below.
It includes a test case for a second bug that was obvious from inspection of the code, which not only doesn't distinguish local vars from field vars, but doesn't distinguish vars from types.
I suspect the fix will be more involved that we have time for at the moment.
$ cat gopls/internal/regtest/marker/testdata/codeaction/extract_issue61496.txt
This test verifies extraction of a function
whose parameters include anonymous struct types.
It is a regression test for issue #61496.
-- go.mod --
module testdata
go 1.18
-- a.go --
package testdata
func _() {
var x struct { y int } //@ codeaction("refactor.extract", "var", end, anon)
println(x.y) //@ loc(end, ")")
}
-- @anon/a.go --
xxx
-- @localtype/b.go --
package testdata
func _() {
type T int
var x T //@ codeaction("refactor.extract", "var", end, anon)
println(x.y) //@ loc(end, ")")
}
-- @localtype/b.go --
xxx
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?darwin, amd64
What did you expect to see?
Refactor of code with anonymous struct completes successfully
What did you see instead?
parent nil
error while extracting code with anonymous structI was able to reproduce the issue in both Neovim and VSCode.
On the demo below, you can see a successful refactor of named struct and then fail on anonymous struct.
https://github.com/golang/go/assets/27726430/f3096917-4158-4bf1-be52-4477863fa454
The text was updated successfully, but these errors were encountered: