-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: bad "invalid composite literal type" error for type parameter with pointer structural type #50833
Comments
Change https://golang.org/cl/381074 mentions this issue: |
Change https://golang.org/cl/381075 mentions this issue: |
CL 381075 appears to be a fairly straightforward fix to this issue, assuming we decide it is an issue. |
I think we probably want to fix this. |
This CL updates unified IR to look at the structural type of a composite literal type, rather than merely the underlying type, to determine if it's a structure. This fixes a number of currently failing regress test cases. Updates #50833. Change-Id: I11c040c77ec86c23e8ffefcf1ce1aed548687dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/381074 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
I'm fine with fixing this for 1.18 but I also think it's OK to let it wait until 1.19. I'm a little bit concerned that we are focusing a bit too much on structural types. At this point I expect them to be a tiny corner case. If anything I think we should focus more on making operations work if they are supported by all elements of a type set that does not have a structural type. But that is definitely for 1.19 or 1.20. If we can make that work, then all these structural type details will be subsumed by the more general, and more useful, case. |
The fix does simplify the code and is arguably more regular, so there's that. |
I'm fine with fixing this for 1.18. |
This CL updates unified IR to look at the structural type of a composite literal type, rather than merely the underlying type, to determine if it's a structure. This fixes a number of currently failing regress test cases. Updates golang#50833. Change-Id: I11c040c77ec86c23e8ffefcf1ce1aed548687dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/381074 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
F below is valid non-generic code, so I'd expect G to compile successfully too. However, go/types and types2 currently reject it.
/cc @griesemer @findleyr @ianlancetaylor
The text was updated successfully, but these errors were encountered: