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
package gopkg
type myStruct struct {
}
func (s *myStruct) myBadFunc() bool { //@rename("myBadFunc", "hello")
return s.Bad // is not a field of myStruct
}
Not sure if any additional information is required to figure this one out, but I am experiencing the same issue.
stamblerre
changed the title
x/tools/internal/lsp: rename fails on struct method that references bad struct field
x/tools/lsp: rename fails on struct method that references bad struct field
Jul 2, 2019
stamblerre
changed the title
x/tools/lsp: rename fails on struct method that references bad struct field
x/tools/gopls: rename fails on struct method that references bad struct field
Jul 2, 2019
The satisfy package has a precondition for Finder.Find that requires
that the package has no type errors. If this is a check that we would
perform, give an error and do not rename.
Fixesgolang/go#32882
Change-Id: Id44b451bf86ff883fd78a6306f2b2565ad3bdeb9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184857
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
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
)?go env
OutputWhat did you do?
go.mod:
gopkg.go
What did you expect to see?
The identifier being renamed to Hello
What did you see instead?
Log of gopls crashing:
[Trace - 5:32:06 PM] Sending request 'textDocument/rename - (19)'.
Params: {"textDocument":{"uri":"file:///Users/suzmue/go/src/golang.org/x/tools/internal/imports/fix.go"},"position":{"line":413,"character":20},"newName":"hello"}
[Error - 5:32:06 PM] send textDocument/rename#19 method "textDocument/rename" did not reply
[Error - 5:32:06 PM] Request textDocument/rename failed.
Message: method "textDocument/rename" did not reply
Code: -32603
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x14babdb]
goroutine 1703 [running]:
golang.org/x/tools/refactor/satisfy.(*Finder).expr(0xc0048b2a20, 0x1784700, 0xc0002753e0, 0x177d000, 0xc0054e0720)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:406 +0xf9b
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc0048b2a20, 0x1784680, 0xc000275440)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:557 +0x11fb
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc0048b2a20, 0x1783f40, 0xc00023ac90)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:572 +0x1939
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc0048b2a20, 0x1784400, 0xc0002cc800)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:580 +0x1a66
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc0048b2a20, 0x1783f40, 0xc00023b080)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:572 +0x1939
golang.org/x/tools/refactor/satisfy.(*Finder).Find(0xc0048b2a20, 0xc0054bd400, 0xc004873300, 0x5, 0x8)
/Users/suzmue/go/src/golang.org/x/tools/refactor/satisfy/find.go:111 +0x193
golang.org/x/tools/internal/lsp/source.(*renamer).satisfy(0xc0004f46e0, 0xc00288b950)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/source/rename_check.go:792 +0x125
golang.org/x/tools/internal/lsp/source.(*renamer).checkMethod(0xc0004f46e0, 0xc0054bda90)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/source/rename_check.go:723 +0x11a
golang.org/x/tools/internal/lsp/source.(*renamer).check(0xc0004f46e0, 0x17906a0, 0xc0054bda90)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/source/rename_check.go:46 +0x343
golang.org/x/tools/internal/lsp/source.(*IdentifierInfo).Rename(0xc003f1e750, 0x1785c80, 0xc004ab5380, 0xc005bc2466, 0x5, 0xc00030e640, 0x5789, 0xc003f1e750)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/source/rename.go:76 +0x5d5
golang.org/x/tools/internal/lsp.(*Server).rename(0xc0001daf80, 0x1785c80, 0xc004ab5380, 0xc0048b28a0, 0x0, 0x0, 0xc004866a00)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/rename.go:34 +0x292
golang.org/x/tools/internal/lsp.(*Server).Rename(0xc0001daf80, 0x1785c80, 0xc004ab5380, 0xc0048b28a0, 0xc0048b28a0, 0x0, 0x0)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/server.go:241 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x1785c80, 0xc004ab5380, 0xc002a1f3e0)
/Users/suzmue/go/src/golang.org/x/tools/internal/lsp/protocol/tsserver.go:415 +0x1291
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0046e2480, 0xc002a1f3e0, 0xc00021a000, 0x1785c80, 0xc004ab5380, 0xc004a59400, 0xc001b03680)
/Users/suzmue/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:441 +0x117
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/Users/suzmue/go/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:428 +0x6fc
[Info - 5:32:06 PM] Connection to server got closed. Server will restart.
The text was updated successfully, but these errors were encountered: