What version of Go are you using (go version)?
$ go version
go version go1.21.3 linux/arm64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/ayke/.cache/go-build'
GOENV='/home/ayke/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ayke/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ayke'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go1.21.3'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go1.21.3/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/ayke/src/ayke/board/go.mod'
GOWORK='/home/ayke/src/ayke/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1813455582=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Run this program: https://go.dev/play/p/jx329NFz7ZU
What did you expect to see?
It compiles.
What did you see instead?
It fails to compile in Go 1.21, while it still compiled in Go 1.20.
Go 1.21 error message:
./prog.go:12:12: cannot infer T (prog.go:15:17)
I have code like this as an assert to verify that v (in the main function) is of a particular type.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
Run this program: https://go.dev/play/p/jx329NFz7ZU
What did you expect to see?
It compiles.
What did you see instead?
It fails to compile in Go 1.21, while it still compiled in Go 1.20.
Go 1.21 error message:
I have code like this as an assert to verify that
v(in the main function) is of a particular type.