You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On go tip (generics), just a reminder that the "cannot infer T" message is confusing at the end:
./test.go:8:11: cannot infer T (test.go:3:8) ([])
I think this is being printed out from {types2,go/types}/infer.go, so the [] is the value of targs, which is the list of inferred and not-inferred type arguments. But especially when there is only one type argument that cannot be inferred, the string '([])' is not meaningful, and may make the user think there is some bigger problem.
If some of the types can be inferred, then the inferred types are included, as in: "([string ])". So, probably just need to print out the inferred args only (with a preceding label), and print out nothing if no targs were inferred.
Here's the simple example program:
package main
func g[T interface{ int64 | int32 }](x int64) T {
return T(x)
}
func main() {
println(g(43))
}
On go tip (generics), just a reminder that the "cannot infer T" message is confusing at the end:
./test.go:8:11: cannot infer T (test.go:3:8) ([])
I think this is being printed out from {types2,go/types}/infer.go, so the [] is the value of targs, which is the list of inferred and not-inferred type arguments. But especially when there is only one type argument that cannot be inferred, the string '([])' is not meaningful, and may make the user think there is some bigger problem.
If some of the types can be inferred, then the inferred types are included, as in: "([string ])". So, probably just need to print out the inferred args only (with a preceding label), and print out nothing if no targs were inferred.
Here's the simple example program:
@griesemer @findleyr
The text was updated successfully, but these errors were encountered: