Skip to content

cmd/compile: internal compiler error on generic type alias in method signature #74274

Open
@bclarkx2

Description

@bclarkx2

Go version

go version go1.24.4 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/bclark/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/bclark/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1037091380=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/bclark/code/reproduce-test-pkg-ice/go.mod'
GOMODCACHE='/home/bclark/projects/go/pkg/mod'
GONOPROXY='github.com/nicheinc'
GONOSUMDB='github.com/nicheinc'
GOOS='linux'
GOPATH='/home/bclark/projects/go'
GOPRIVATE='github.com/nicheinc'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='off'
GOTELEMETRYDIR='/home/bclark/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I attempted to compile a Go program with a couple features:

  • A generic struct type parameterized by T any.
  • A generic type alias for a function type that accepts an argument of the above generic struct type.
  • The generic type alias is used in the signature of a method on the generic struct type.
  • A generic function that uses the generic type alias in its signature is defined and invoked in the program.

Here is a playground reproduction of the ICE: https://go.dev/play/p/aLssEM_X0_N

As near as I can tell, this is a minimum reproducible example -- any of these variations don't produce the ICE:

What did you see happen?

When compiling a program like this one, I see an internal compiler error stemming from the line containing the generic type alias.

$ go build .
# github.com/nicheinc/reproduce-test-pkg-ice
./main.go:5:2: internal compiler error: assertion failed

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

I expected the program to compile without error.1

Footnotes

  1. I figure from reading the spec that this should be legal Go code and compile without error rather than producing a compiler error, so my apologies if that's not the case!

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.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions