-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: non-exported anonymous field handling #7522
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
Labels
Milestone
Comments
In my opinion it would not be correct to revert the change. The change was to the type reflection information, and I believe it was correct (though it should be clearly documented in the 1.3 changes, which I think is not yet the case). What I'm wondering is whether we can make encoding/json continue to work as it did before. |
Either the reflection logic is now incorrect, or the compiler is. This tiny program shows the divergence more clearly: https://gist.github.com/niemeyer/ed26a8784b0f0b5da733 That used to work fine, and it doesn't anymore. This is breaking existing packages and applications, breaking the Go1 promise, and making the compiler and the reflect package disagree. Can we please consider that more carefully, perhaps not in Go 1.3? |
I lie, sorry. This is broken for unrelated reasons. This is the correct one: https://gist.github.com/niemeyer/c2ca054af6b6f8dfe4dc |
6c0339d94123 introduces a similar breakage in XML, which in turn breaks a bunch of other stuff, like go.text/cldr. Also, it introduces what I think is a bug in reflect. I don't think 6c0339d94123 is correct, in that it may fix things, but also breaks things. From the Go spec on embedding: A field or method f of an anonymous field in a struct x is called promoted if x.f is a legal selector that denotes that field or method f. Promoted fields act like ordinary fields of a struct except that they cannot be used as field names in composite literals of the struct. The behavior in Go is consistent with this, even when it applies to exported fields of unexported structs: a.C = "foo" works, as per the definition, and a{C: "foo"} does not, also per the definition. If we allow exported fields of unexported structs to be promoted by this mechanism, it should be consistent with reflect's behavior in my opinion. However, since 6c0339d94123 a variable that is visible and accessible by virtue of the "promotion rule" cannot be set despite the same rule. I would suggest reverting the change until this is fixed. It results in more breakage than that it fixes, it seems to me. |
CL https://golang.org/cl/78500044 references this issue. |
CL https://golang.org/cl/85580046 mentions this issue. |
CL https://golang.org/cl/85580046 mentions this issue. |
This issue was closed by revision c48db9a. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: