Skip to content

x/tools/gopls: interface conversion: types.Object is *types.Var, not *types.Func #67975

Not planned
@yeaha

Description

@yeaha

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>

Activity

findleyr

findleyr commented on Jun 13, 2024

@findleyr
Member

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?

changed the title [-]gopls: automated issue report (crash)[/-] [+]x/tools/gopls: interface conversion: types.Object is *types.Var, not *types.Func[/+] on Jun 13, 2024
transferred this issue fromgolang/vscode-goon Jun 13, 2024
added
ToolsThis label describes issues relating to any tools in the x/tools repository.
goplsIssues related to the Go language server, gopls.
on Jun 13, 2024
added this to the Unreleased milestone on Jun 13, 2024
adonovan

adonovan commented on Jun 13, 2024

@adonovan
Member

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

findleyr commented on Jun 18, 2024

@findleyr
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yeaha@adonovan@gopherbot@findleyr@gabyhelp

        Issue actions

          x/tools/gopls: interface conversion: types.Object is *types.Var, not *types.Func · Issue #67975 · golang/go