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

go/types, types2: gopls crash on method with type parameters #50427

Closed
KarlShing opened this issue Jan 4, 2022 · 4 comments
Closed

go/types, types2: gopls crash on method with type parameters #50427

KarlShing opened this issue Jan 4, 2022 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@KarlShing
Copy link

gopls version: v0.7.4
gopls flags:
update flags: proxy
extension version: 0.30.0
go version: devel go1.18-95b240b2cd
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Tue, 04 Jan 2022 06:54:46 GMT
restart history:
Tue, 04 Jan 2022 06:54:38 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: method with type parameters

goroutine 178 [running]:
go/types.(*Checker).handleBailout(0xc0004921c0, 0xc000845688)
	  check.go:279  0x8b
panic({0x1852500, 0x1bca4b0})
	  panic.go:838  0x207
go/types.(*Checker).missingMethod(0xc0004921c0, {0x1bcfba0%3F, 0xc000522980%3F}, 0xc00014dbc0, 0x1)
	  lookup.go:376  0x48e
go/types.(*operand).assignableTo(0xc000b18980, 0xc0004921c0, {0x1bcfba0%3F, 0xc000522a80%3F}, 0xc000843a90)
	  operand.go:283  0x469
go/types.(*Checker).assignment(0xc0004921c0, 0xc000b18980, {0x1bcfba0, 0xc000522a80}, {0xc0008c40f0, 0x12})
	  assignments.go:87  0x80a
go/types.(*Checker).arguments(0xc0004921c0, 0xc000c07080, 0xc0009005c0, {0xc000726b20, 0x1, 0x1}, {0xc000726b30%3F, 0x2, 0x2}, {0xc000726b10, ...})
	  call.go:410  0xbf4
go/types.(*Checker).callExpr(0xc0004921c0, 0xc000b188c0, 0xc000c07080)
	  call.go:206  0x669
go/types.(*Checker).exprInternal(0xc0004921c0, 0xc000b188c0, {0x1bd1c10%3F, 0xc000c07080}, {0x0%3F, 0x0%3F})
	  expr.go:1470  0xa12
go/types.(*Checker).rawExpr(0xc000600000%3F, 0xc000b188c0%3F, {0x1bd1c10%3F, 0xc000c07080%3F}, {0x0%3F, 0x0%3F}, 0x0)
	  expr.go:1094  0x45
go/types.(*Checker).multiExpr(0xc000844840%3F, 0x128adb1%3F, {0x1bd1c10%3F, 0xc000c07080%3F})
	  expr.go:1600  0x35
go/types.(*Checker).exprList(0xc000844960%3F, {0xc0005ac370%3F, 0xc0004921c0%3F, 0x1bcfba0%3F}, 0x0)
	  call.go:249  0x97
go/types.(*Checker).initVars(0x10043c9%3F, {0xc0003ec1f0, 0x1, 0xc000c06c00%3F}, {0xc0005ac370, 0x1, 0x0%3F}, {0x1bd2150, 0xc000c011c0})
	  assignments.go:318  0x89
go/types.(*Checker).stmt(0xc0004921c0, 0x0, {0x1bd2150%3F, 0xc000c011c0%3F})
	  stmt.go:522  0x19ce
go/types.(*Checker).stmtList(0x100e8c5%3F, 0x0, {0xc0005ac380%3F, 0xc000901300%3F, 0x50%3F})
	  stmt.go:125  0xc9
go/types.(*Checker).funcBody(0xc0004921c0, 0xc00014d320, {0xc000b22780%3F, 0x1%3F}, 0xc000901000, 0xc00058ec30, {0x0, 0x0})
	  stmt.go:46  0x285
go/types.(*Checker).funcDecl.func1()
	  decl.go:876  0x45
go/types.(*Checker).processDelayed(0xc0004921c0, 0x0)
	  check.go:348  0x39
go/types.(*Checker).checkFiles(0xc0004921c0, {0xc0003ec018%3F, 0xc000b98000%3F, 0x2%3F})
	  check.go:301  0xcb
go/types.(*Checker).Files(...)
	  check.go:284
golang.org/x/tools/internal/lsp/cache.doTypeCheck({0x1bd32d8, 0xc0006a0000}, 0xc0002aa200, 0xc00094a1e0, 0x2, 0xc0002c11d0, 0x0%3F)
	  check.go:536  0x8b3
golang.org/x/tools/internal/lsp/cache.typeCheck({0x1bd32d8, 0xc0006a0000}, 0xc0002aa200, 0xc00094a1e0, 0x2, 0xc0002c11d0%3F)
	  check.go:313  0xe5
golang.org/x/tools/internal/lsp/cache.(*snapshot).buildPackageHandle.func1({0x1bd32d8%3F, 0xc0006a0000}, {0x1bccbe0%3F, 0xc0002aa200})
	  check.go:124  0x233
golang.org/x/tools/internal/memoize.(*Handle).run.func1()
	  memoize.go:327  0xa9
created by golang.org/x/tools/internal/memoize.(*Handle).run
	  memoize.go:320  0x1b8
[Error - 2:54:39 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>

@hyangah hyangah changed the title Jan 4, 2022
@hyangah hyangah transferred this issue from golang/vscode-go Jan 4, 2022
@gopherbot 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 Jan 4, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 4, 2022
@findleyr findleyr changed the title x/tools/gopls: automated issue report (crash) - "method with type parameters" go/types, types2: gopls crash on method with type parameters Jan 4, 2022
@findleyr findleyr modified the milestones: Unreleased, Go1.18 Jan 4, 2022
@findleyr findleyr added release-blocker NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 4, 2022
@findleyr
Copy link
Contributor

findleyr commented Jan 4, 2022

This is really an issue with go/types, so I've remilestoned and labeled accordingly.

CC @griesemer

@findleyr findleyr removed the gopls Issues related to the Go language server, gopls. label Jan 4, 2022
@griesemer
Copy link
Contributor

@findleyr This panic can be only be reached if a method has type parameters. The go/parser does accept type parameters on methods, and it appears that go/types doesn't complain in the resolver (types2 complains in the resolver). go/types then complains in Checker.funcType but seems to collect them anyway. So it seems plausible that they make it all the way into missingMethod.

@findleyr
Copy link
Contributor

findleyr commented Feb 2, 2022

Simple reproducer:

type T interface{ m[P any]() }

func _(t T) {
	var _ interface{ m[P any](); n() } = t
}

Interestingly this does not repro in types2, though there may be other codepaths that panic.

@gopherbot
Copy link

Change https://golang.org/cl/382538 mentions this issue: go/parser, go/types: don't parse type parameters on methods

@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants