Skip to content

go/types: alias TypeName has nil typ #77321

Description

@adonovan
#!stacks
"gopanic" && "go/types.(*typeWriter).error:=110"

Issue created by stacks.

This looks like an alias bug in the type checker: the crash indicates that a TypeName's obj.typ field is nil.

func (w *typeWriter) typ(typ Type) {
...	switch t := typ.(type) {
	case nil:
		w.error("nil") // panics

Called from:

func (w *typeWriter) typ(typ Type) {
...
	case *Alias:
		w.typeName(t.obj) // dereferences t.obj.{pkg,name}
	...
		w.typ(Unalias(t.obj.typ)) // w.typ arg was nil => Unalias returned nil => t.obj.typ is nil

It's also possibly just another instance of memory corruption.

This stack UAPFHA was reported by telemetry:

golang.org/x/tools/gopls@v0.21.0 go1.26rc2 linux/amd64 gopls.client=neovim (1)

Use this command to reproduce the executable:
(HOME=$(mktemp -d); GOOS=linux GOARCH=amd64 GOTOOLCHAIN=go1.26rc2 go install golang.org/x/tools/gopls@v0.21.0 && find $HOME/go/bin -type f)
To disassemble: go tool objdump exe | less
Dups: 1VpMXw 0R0w6A HwXxCg Uwn_Cw A1V8tg

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.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

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions