You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SA1019: "unsupported selector" panic on generic struct literal with deprecated field #1821
SA1019 panics with unsupported selector when a composite literal of an
instantiated generic struct sets a deprecated field.
This only happens when the literal is in a different package than the struct
type, because SA1019 doesn't report uses inside the package that declares the
type.
Reproducer
-- go.mod --
module example.com/repro
go 1.27
-- a/a.go --
package a
type Params[T any] struct {
// Deprecated: use New instead.
Old string
New T
}
-- b/b.go --
package b
import "example.com/repro/a"
var _ = a.Params[int]{Old: "x"}
$ go run honnef.co/go/tools/cmd/staticcheck@v0.8.1 -checks SA1019 ./...panic: unsupported selector: &{0x2211e9f2d6b0 Old}goroutine 519 [running]:honnef.co/go/tools/analysis/code.SelectorName(0x2211ea3dfc00, 0x2211ea24f2c0) honnef.co/go/tools@v0.8.1/analysis/code/code.go:104 +0x454honnef.co/go/tools/staticcheck/sa1019.run.func3(0x2211ea24f2c0) honnef.co/go/tools@v0.8.1/staticcheck/sa1019/sa1019.go:156 +0x394
If Params isn't generic, SA1019 reports Old as deprecated and doesn't
panic, so the panic only happens with instantiated generic types.
Versions
$ staticcheck -versionstaticcheck 2026.2.1 (0.8.1)
$ go versiongo version go1.27.1 linux/amd64
GOOS=linux GOARCH=amd64. Also reproduces on master.
changed the title [-]SA1019: panic "unsupported selector" on composite literals of generic structs with deprecated fields[/-][+]SA1019: "unsupported selector" panic on generic struct literal with deprecated field[/+]on Oct 1, 2026
Activity
[-]SA1019: panic "unsupported selector" on composite literals of generic structs with deprecated fields[/-][+]SA1019: "unsupported selector" panic on generic struct literal with deprecated field[/+]analysis/code: handle selectors on instantiated generic types
analysis/code: handle selectors on instantiated generic types