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: interface conversion: types.Object is *types.Var, not *types.Func #67975

Closed
yeaha opened this issue Jun 13, 2024 · 4 comments
Closed
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@yeaha
Copy link

yeaha commented Jun 13, 2024

gopls version: v0.15.3/go1.22.1
gopls flags:
update flags: proxy
extension version: 0.41.4
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Thu, 13 Jun 2024 09:17:59 GMT
restart history:
Wed, 12 Jun 2024 03:35:37 GMT: activation (enabled: true)
Wed, 12 Jun 2024 05:06:05 GMT: manual (enabled: true)
Wed, 12 Jun 2024 05:07:03 GMT: manual (enabled: true)
Thu, 13 Jun 2024 09:17:52 GMT: manual (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: interface conversion: types.Object is *types.Var, not *types.Func

goroutine 4625 [running]:
golang.org/x/tools/internal/typeparams.OriginMethod(0xc001cf8ae0)
	  common.go:134  0x248
golang.org/x/tools/gopls/internal/cache/methodsets.(*indexBuilder).build.func2(0xc002575340, 0xc001cf8ae0)
	  methodsets.go:232  0x1c5
golang.org/x/tools/gopls/internal/cache/methodsets.methodSetInfo({0x128f310, 0xc000188e70}, 0xc00225baf8)
	  methodsets.go:293  0x238
golang.org/x/tools/gopls/internal/cache/methodsets.(*indexBuilder).build(0xc00225bb78, 0xc001864b80, 0xc001bf5140)
	  methodsets.go:245  0x49d
golang.org/x/tools/gopls/internal/cache/methodsets.NewIndex(...)
	  methodsets.go:82
golang.org/x/tools/gopls/internal/cache.(*syntaxPackage).methodsets.func1()
	  pkg.go:79  0x45
sync.(*Once).doSlow(0xc0000ec808%3F, 0xc0000ece10%3F)
	  once.go:74  0xc2
sync.(*Once).Do(...)
	  once.go:65
golang.org/x/tools/gopls/internal/cache.(*syntaxPackage).methodsets(0xc002802780)
	  pkg.go:78  0x4a
golang.org/x/tools/gopls/internal/cache.storePackageResults({0x1293c28, 0xc001bb7c80}, 0xc0020bcb40, 0xc002d35200)
	  check.go:583  0x137
created by golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage in goroutine 4606
	  check.go:570  0x69b
gopls stats -anon { "DirStats": { "Files": 55, "TestdataFiles": 0, "GoFiles": 11, "ModFiles": 1, "Dirs": 27 }, "GOARCH": "amd64", "GOOS": "linux", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.1", "GoplsVersion": "v0.15.3", "InitialWorkspaceLoadDuration": "795.365217ms", "MemStats": { "HeapAlloc": 19938456, "HeapInUse": 32956416, "TotalAlloc": 309115200 }, "WorkspaceStats": { "Files": { "Total": 1090, "Largest": 395026, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.1", "AllPackages": { "Packages": 177, "LargestPackage": 161, "CompiledGoFiles": 1090, "Modules": 11 }, "WorkspacePackages": { "Packages": 4, "LargestPackage": 8, "CompiledGoFiles": 15, "Modules": 1 }, "Diagnostics": 0 } ] } }

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

Thanks, this is a new one. Transferring to the gopls issue tracker.

Can you share any information about the code you were editing when this occurred? Is this reproducible?

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: interface conversion: types.Object is *types.Var, not *types.Func Jun 13, 2024
@findleyr findleyr transferred this issue from golang/vscode-go Jun 13, 2024
@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 Jun 13, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 13, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.16.0 Jun 13, 2024
@adonovan
Copy link
Member

adonovan commented Jun 13, 2024

Thanks for the report. I suspect that there's a generic named type with both a field and a method of the same name. Of course this is not a valid program, but it shouldn't crash the indexer. However I'm unable to reproduce it. I did find a different bug, which I will report separately.

type Foo[T any] struct{ XXX string }
func (Foo[T]) XXX() {} // References on XXX => bug.ReportKeyOf(%s)={} yet func %s is a method"

In any case, there's a good chance this is fixed in the 0.16 pre-release, since we threw away all the old OriginMethod logic. (See also #61196, which was a similar bug in it.)

@findleyr
Copy link
Contributor

I couldn't reproduce but this should indeed be obsolete. We no longer use the panicking OriginMethod logic.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants