-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
go/types, types2: conversions involving type parameters don't work #47150
Comments
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. |
Updated test cases. package p
func convert1[Dst ~int, Src ~int](x Src) Dst { return Dst(x) }
func convert2[Dst ~string, Src ~int](x Src) Dst { return Dst(x) }
func convert3[Dst ~string, Src ~string](x Src) Dst { return Dst(x) }
func convert4[Dst ~int|~string, Src ~int](x Src) Dst { return Dst(x) }
func convert5[Dst ~string, Src ~int|~string](x Src) Dst { return Dst(x) } |
@ianlancetaylor I am certainly expecting |
Seems fine to me. But presumably these will work: func convert6[Dst ~string, Src ~byte](x Src) Dst { return Dst(x) }
func convert7[Dst ~string, Src ~rune](x Src) Dst { return Dst(x) } |
Yes, those will work. Should have a CL with all expected conversions soon. |
Change https://golang.org/cl/356010 mentions this issue: |
Change https://golang.org/cl/357333 mentions this issue: |
…conversions Iterate through the actual, possibly defined types of constraints when type-checking generic conversions, not the underlying types. For #47150. Change-Id: Ia7af313bf46d6f6b0ad5292ff793b030b8e2d3d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/357333 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Change https://golang.org/cl/357249 mentions this issue: |
… conversions - slightly refactor convertibleTo and convertibleToImpl - provide ability to return a conversion failure cause - add detailed cause for generic conversions For #47150. Change-Id: Ie97d89be0234414ef4df22a6920e18acc944a102 Reviewed-on: https://go-review.googlesource.com/c/go/+/357249 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Reminder issue that conversions involving type parameters are implemented ad-hoc and don't work as expected.
For instance (https://go2goplay.golang.org/p/8MHhIOoWA29):
(test case by @mdempsky)
See also the section on type conversions in the generics proposal.
cc: @findleyr
The text was updated successfully, but these errors were encountered: