What version of Go are you using (go version)?
$ go version
go version go1.18beta1 linux/amd64
Does this issue reproduce with the latest release?
N/A. Type parameters are not available in any other version that are currently available.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOVERSION="go1.18beta1"
What did you do?
package main
import (
"fmt"
)
func main() {
foo := &Foo[string, int]{
valueA: "i am a string",
valueB: 123,
}
fmt.Println(foo)
}
type Foo[T1 any, T2 any] struct {
valueA T1
valueB T2
}
func (f *Foo[_,_]) String() string {
return fmt.Sprintf("%v %v", f.valueA, f.valueB)
}
What did you expect to see?
I expected the code snippet above to build and run successfully.
What did you see instead?
Build error:
<autogenerated>:1: cannot use .this (type *Foo[string,int]) as type *Foo[go.shape.string_0,go.shape.string_0] in argument to (*Foo[go.shape.string_0,go.shape.int_1]).String
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
N/A. Type parameters are not available in any other version that are currently available.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
What did you expect to see?
I expected the code snippet above to build and run successfully.
What did you see instead?
Build error: