Skip to content
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 when renaming in a package using builtins with type parameters #52940

Closed
dalianzhu opened this issue May 17, 2022 · 7 comments
Closed
Assignees
Labels
gopls/generics NeedsInvestigation
Milestone

Comments

@dalianzhu
Copy link

@dalianzhu dalianzhu commented May 17, 2022

gopls version: v0.8.3 (go1.18)
gopls flags:
update flags: proxy
extension version: 0.33.0
go version: 1.18
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Tue, 17 May 2022 09:09:54 GMT
restart history:
Mon, 16 May 2022 05:09:54 GMT: activation (enabled: true)
Tue, 17 May 2022 08:52:58 GMT: manual (enabled: true)
Tue, 17 May 2022 09:03:47 GMT: manual (enabled: true)
Tue, 17 May 2022 09:09:14 GMT: manual (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: interface conversion: types.Type is *types.Interface, not *types.Slice

goroutine 28167 [running]:
golang.org/x/tools/refactor/satisfy.(*Finder).builtin(0xcea600%3F, 0xc0083cf440%3F, 0xc00a874ea0%3F, {0xc00a874f20%3F, 0x2, 0x2}, {0x1053748, 0xc021741380})
	  find.go:221  0x32f
golang.org/x/tools/refactor/satisfy.(*Finder).expr(0xc028780570, {0x1055968%3F, 0xc00b41cdc0%3F})
	  find.go:442  0xe72
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x10557e8%3F, 0xc00b41ce00%3F})
	  find.go:522  0xd5b
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x1055908%3F, 0xc00b21b2c0%3F})
	  find.go:572  0xbc5
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x1055c98%3F, 0xc00b41cec0%3F})
	  find.go:580  0xafe
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x1055908%3F, 0xc00b21b410%3F})
	  find.go:572  0xbc5
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x1055e78%3F, 0xc00b12fa40%3F})
	  find.go:686  0x7f7
golang.org/x/tools/refactor/satisfy.(*Finder).stmt(0xc028780570, {0x1055908%3F, 0xc00b21b500%3F})
	  find.go:572  0xbc5
golang.org/x/tools/refactor/satisfy.(*Finder).Find(0xc028780570, 0xc0148581e0%3F, {0xc0228bdc00, 0x13, 0x1%3F})
	  find.go:111  0x1c5
golang.org/x/tools/internal/lsp/source.(*renamer).satisfy(0xc01ebd1ea0)
	  rename_check.go:800  0xdc
golang.org/x/tools/internal/lsp/source.(*renamer).checkMethod(0xc01ebd1ea0, 0xc02e2a2af0)
	  rename_check.go:718  0x2d4
golang.org/x/tools/internal/lsp/source.(*renamer).check(0xc01ebd1ea0, {0x105dbc8, 0xc02e2a2af0%3F})
	  rename_check.go:46  0x16b
golang.org/x/tools/internal/lsp/source.Rename({0x1057048%3F, 0xc018efe1c0%3F}, {0x105fb00, 0xc049e80ea0}, {0x1057390, 0xc0492c0420}, {0x49299638%3F, 0xc0%3F}, {0xc0278fa736, 0xa})
	  rename.go:148  0x945
golang.org/x/tools/internal/lsp.(*Server).rename(0xc96240%3F, {0x1057048, 0xc018efe1c0}, 0xc018fd6100)
	  rename.go:20  0x10d
golang.org/x/tools/internal/lsp.(*Server).Rename(0xc019b74000%3F, {0x1057048%3F, 0xc018efe1c0%3F}, 0xc96240%3F)
	  server_gen.go:224  0x25
golang.org/x/tools/internal/lsp/protocol.serverDispatch({0x1057048, 0xc018efe1c0}, {0x1063670, 0xc000494000}, 0xc028780000, {0x10572e8, 0xc018efe040})
	  tsserver.go:592  0xbba
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1({0x1057048, 0xc018efe1c0}, 0xc028780000, {0x10572e8, 0xc018efe040})
	  protocol.go:154  0x90
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1({0x1057048, 0xc018efe1c0}, 0xc028780000, {0x10572e8%3F, 0xc018efe040%3F})
	  lsprpc.go:512  0xa43
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x1057048, 0xc018efe1c0}, 0xc02c686de0, {0x10572e8%3F, 0xc018efe040%3F})
	  handler.go:35  0xf6
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2()
	  handler.go:103  0xa3
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x20a
[Error - 5:09:36 PM] 

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@findleyr
Copy link
Contributor

@findleyr findleyr commented May 17, 2022

It looks like Finder.builtin does not handle core types for type parameters.

CC @adonovan

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: crash when renaming in a package using builtins with type parameters May 17, 2022
@findleyr findleyr transferred this issue from golang/vscode-go May 17, 2022
@gopherbot gopherbot added Tools gopls labels May 17, 2022
@gopherbot gopherbot added this to the Unreleased milestone May 17, 2022
@findleyr findleyr added NeedsInvestigation and removed gopls Tools labels May 17, 2022
@findleyr
Copy link
Contributor

@findleyr findleyr commented May 17, 2022

It looks like there's a fair bit of work to be done in the satisfaction checker, and we'll need an implementation of the core type algorithm.

I believe @timothy-king has this on a branch. Tim, would you mind upstreaming your implementation of coreType into the x/tools/internal/typeparams package (or would you mind if I did it)?

@findleyr findleyr removed this from the Unreleased milestone May 17, 2022
@findleyr findleyr added this to the gopls/later milestone May 17, 2022
@timothy-king
Copy link
Contributor

@timothy-king timothy-king commented May 17, 2022

I can upstream an initial version. May need some additional polish as a follow-up.

@findleyr
Copy link
Contributor

@findleyr findleyr commented May 17, 2022

@timothy-king that would be great. We can get some experience with it. Thanks!

@gopherbot
Copy link

@gopherbot gopherbot commented May 17, 2022

Change https://go.dev/cl/406838 mentions this issue: internal/typeparams: adds core type implementation

gopherbot pushed a commit to golang/tools that referenced this issue May 17, 2022
Adds a function for computing the core type of a type for use within x/tools.

Updates golang/go#52940

Change-Id: I91645c0b27031506be51a5f9d53b3e125e6fd1c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/406838
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@findleyr findleyr added the gopls/generics label May 18, 2022
@findleyr findleyr removed this from the gopls/later milestone May 18, 2022
@findleyr findleyr added this to the gopls/v0.9.0 milestone May 18, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 24, 2022

Change https://go.dev/cl/413682 mentions this issue: refactor/satisfy: recover from unexpected panics

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 24, 2022

Change https://go.dev/cl/413690 mentions this issue: refactor/satisfy: don't crash on type parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/generics NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

5 participants