Skip to content

"Internal error: unhandled case *types.Interface" when embedding any in a struct #1361

@tulir

Description

@tulir

Started in v0.4.0. v0.3.3 doesn't panic

$ cat test.go 
package main

type Foo struct {
	any
}
$ staticcheck test.go
panic: internal error: unhandled case *types.Interface

goroutine 55 [running]:
honnef.co/go/tools/analysis/lint.ExhaustiveTypeSwitch(...)
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/analysis/lint/lint.go:234
honnef.co/go/tools/unused.(*graph).embeddedField(0xc00059fcb0, {0xa25438?, 0xc0003fa5c0?}, {0xa2d098, 0xc00039d180})
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/unused/unused.go:1413 +0x58a
honnef.co/go/tools/unused.(*graph).namedType(0xc00059fcb0, 0xa252f8?, {0xa27298?, 0xc0004870b0?})
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/unused/unused.go:1502 +0x27c
honnef.co/go/tools/unused.(*graph).decl(0xc00059fcb0, {0xa26ed8?, 0xc000489140?}, {0x0, 0x0})
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/unused/unused.go:1099 +0xab2
honnef.co/go/tools/unused.(*graph).entry(0xc00059fcb0)
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/unused/unused.go:518 +0xc3c
honnef.co/go/tools/unused.run(0xc0002fa2d0)
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/unused/unused.go:219 +0x245
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc0004e0030, {0xa28278?, 0xc0004cf4a0})
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/lintcmd/runner/runner.go:992 +0x63c
honnef.co/go/tools/lintcmd/runner.genericHandle({0xa28278?, 0xc0004cf4a0}, {0xa28278?, 0xc000390f00?}, 0x0?, 0xc000410740, 0xc0002828d0)
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/lintcmd/runner/runner.go:817 +0x102
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers
	$GOPATH/pkg/mod/honnef.co/go/[email protected]/lintcmd/runner/runner.go:1061 +0x70a
$ staticcheck -debug.version
staticcheck 2023.1 (v0.4.0)

Compiled with Go version: go1.19.3
Main module:
	honnef.co/go/[email protected] (sum: h1:lyXVV1c8wUBJRKqI8JgIpT8TW1VDagfYYaxbKa/HoL8=)
Dependencies:
	github.com/BurntSushi/[email protected] (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=)
	golang.org/x/exp/[email protected] (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=)
	golang.org/x/[email protected] (sum: h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=)
	golang.org/x/[email protected] (sum: h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=)
	golang.org/x/[email protected] (sum: h1:9ZNWAi4CYhNv60mXGgAncgq7SGc5qa7C8VZV8Tg7Ggs=)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions