What version of Go are you using (go version)?
$ go version
go version devel go1.18-051df0d722 Wed Sep 22 03:45:00 2021 +0000 windows/amd64
Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=[...]
set GOENV=[...]
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=[...]
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=[...]
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=[...]
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=[...]
set GOVCS=
set GOVERSION=devel go1.18-051df0d722 Wed Sep 22 03:45:00 2021 +0000
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=[...]
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=[...]/tmp/go-build -gno-record-gcc-switches
What did you do?
package main
type MyType[T any] struct{}
func (m MyType[T]) F1(arg T) {}
func (m MyType[T]) F2() {
n := MyType[T]{}
m.F1(n)
}
What did you expect to see?
Successful compilation, since MyType[T] implements any.
What did you see instead?
incompatible type: cannot use n (variable of type MyType[T]) as T value
I'm not sure this is a bug, but I even if I read the design document, I don't really understand why I have this error. Even using https://golang.org/cl/350697 gave me no reason.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
What did you expect to see?
Successful compilation, since
MyType[T]implementsany.What did you see instead?
I'm not sure this is a bug, but I even if I read the design document, I don't really understand why I have this error. Even using https://golang.org/cl/350697 gave me no reason.