Closed
Description
What version of Go are you using (go version
)?
$ go version devel +ad307489d4 Tue Jun 16 05:49:35 2020 +0000.
Does this issue reproduce with the latest release?
No. It's a dev branch.
What operating system and processor architecture are you using (go env
)?
I'm using https://go2goplay.golang.org/.
What did you do?
package main
type Result(type T) struct {
t T
}
func F(type T)(v Result(T)) (Result(T)) {
return v
}
What did you expect to see?
The code should be compiled
What did you see instead?
type checking failed for main
prog.go2:8:9: cannot use v (variable of type Result(T)) as T value in return statement
The return type of F should be Result(T), but the compiler thinks it's T, treating the definition as func F(type T)(v Result(T)) (Result T)
.