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: panic on generic struct literal #48538
Comments
See also #45396 |
I tried to analyze this problem. go/src/cmd/compile/internal/types2/expr.go Line 1282 in 91c2318
like this, check.recordTypeAndValue(key, variable, etyp, nil) or may be need to record the value too, like this check.recordTypeAndValue(key, variable, etyp, constant.Make(kv.Value))
But there are still other problems, will Fatalf when transform
hope it will be helpful to who fix the problem in the future. |
@griesemer @findleyr Unusual case where the type of the return value of f is strictly (and only) determined by the type constraint C which specifies a specific struct type. I'm assuming that's why types2 is not returning a type (as it normally does) for the b1 field of A in the struct literal. If we don't want to disallow this case somehow, then I guess types2 has to understand and use the type of A from the type constraint, so it can give a real type for b1. |
Per discussion, the issue here is that we need to agree upon what to do exactly with underlying/operational types of type parameters. Once we have made that decision, this (and many other cases) should fall out naturally. |
Friendly ping that this issue is marked as a release-blocker for Go 1.18. Are there any updates? |
This is easy to address but needs a decision. Notably, the type checker accepts this at the moment, but perhaps it shouldn't, at least for now. @ianlancetaylor any thoughts? |
Robert has a |
Change https://golang.org/cl/359275 mentions this issue: |
For #48538. Change-Id: I258b0c8af5801692ad238e47397dde0b4e3c44c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/359275 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com>
This program is now considered valid and will be accepted by the type checker because |
Change https://golang.org/cl/359335 mentions this issue: |
commit a83a558
I compiled this program:
I saw this panic:
The text was updated successfully, but these errors were encountered: