New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: inconsistent generics behaviour #48389
Comments
Looks like a bug to me. There's several issues around conversions that we need to address. |
Checking in on this issue as it's labeled a release blocker for Go 1.18. Is there any update? |
This will be worked on soon. |
Also another case: func toStrings[T ~string|~[]byte](in []T) []string {
out := make([]string, 0, len(in))
for _, v := range in {
out = append(out, string(v))
}
return out
} |
Another issue which may be closely related. This code should work but doesn't.
https://go2goplay.golang.org/p/JyUKVBNOFfX
|
Generic conversions are now implemented in the compiler (port to |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Latest master
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The below programs fails to build with error whereas a similar program with string replaced with int compiles fine. Not sure if this is a bug or expected.
./main4.go:9:16: cannot convert in (variable of type parameter T constrained by Constraint) to string
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: