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: * Using a generic type definition rather than a generic type alias (!): https://go.dev/play/p/YQPOgxTmT8c * Not invoking the generic function: https://go.dev/play/p/jpLOae1PLsT * Using the generic type alias in a standalone generic function rather than as a method of the generic struct type: https://go.dev/play/p/ZktpdJXZpu1
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
Comment From: gabyhelp
Related Issues
- cmd/compile: internal compiler error: assertion failed #54028 (closed)
- cmd/compile: ICE instantiating a generic type `B` in `type A[T] struct{}; type B[T] A[[]T]` with `error` #56626 (closed)
- cmd/compile: type inference fails for unused type in generic type alias #70948 (closed)
- cmd/compile: panic when declaring method on generic alias #70417 (closed)
- internal compile error caused by function type alias #36419 (closed)
- cmd/compile: assertion failure compiling embedded method on parameterized type #47797 (closed)
- generics: a type declarations inside generic functions in some cases is not reported in the error report #50726 (closed)
- cmd/compile: internal compiler error using type parameters with local type alias #48184 (closed)
- cmd/compile: crash while exporting aliases (with GODEBUG=gotypesalias=1) #66550 (closed)
- cmd/compile: ICE on slice of array pointer returned by a generic function #71184 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: JunyangShao
@golang/compiler @griesemer @mrkfrmn I am not sure if it's a duplicate of #74181. They do look failing at different part of the compiler based on the error message though :D.
Comment From: cuonglm
All above programs run ok with current tip, fyi.
Comment From: griesemer
I don't think it's a duplicate of #74181 because #74181 still fails on the 1.25 release branch.
Comment From: cuonglm
Likely duplicated of #66873 and #73309.
-
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! ↩