8000 SA1019: "unsupported selector" panic on generic struct literal with deprecated field · Issue #1821 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

SA1019: "unsupported selector" panic on generic struct literal with deprecated field #1821

Closed

Description

@moisesvega

What happened

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 +0x454
honnef.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 -version
staticcheck 2026.2.1 (0.8.1)

$ go version
go version go1.27.1 linux/amd64

GOOS=linux GOARCH=amd64. Also reproduces on master.

Activity

  1. 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
  2. added a commit that references this issue on Oct 11, 2026
    22c3391
  3. added a commit that references this issue on Oct 12, 2026
    87e288b
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0