Skip to content

x/tools/gopls: ast.StructType has type other than types.StructType (no type?) #69150

@adonovan

Description

@adonovan

This stack iWGuoA was reported by telemetry:

xtools/gopls/internal/golang/hover.go:

	if v, ok := obj.(*types.Var); ok && v.IsField() {
		// Find enclosing struct type.
		var tStruct *types.Struct
		for _, n := range path {
			if n, ok := n.(*ast.StructType); ok {
				tStruct = pkg.TypesInfo().TypeOf(n).(*types.Struct) // type assertion failed
				break
			}
		}

I think this must mean TypeOf returned nil (some other type for ast.StructType seems unlikely). If so, the underlying bug is in the type checker.

crash/crash
runtime.gopanic:+69
runtime.panicdottypeE:=275
runtime.panicdottypeI:+5
golang.org/x/tools/gopls/internal/golang.computeSizeOffsetInfo:+40
golang.org/x/tools/gopls/internal/golang.hover:+186
golang.org/x/tools/gopls/internal/golang.Hover:+4
golang.org/x/tools/gopls/internal/server.(*server).Hover:+30
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+335
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/[email protected] go1.23.0 darwin/arm64 vscode (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/telemetry-wins

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions