-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
reflect: permit unexported fields in StructOf #25401
Comments
Change https://golang.org/cl/115015 mentions this issue: |
It looks the modified docs is still not accurate.
In fact, for gc, if the number of methods is no more than 32 for the new created struct type, the wrapper methods are generated without problems. #25402
Maybe, the following description is better
|
Can we get this fixed so it is allowed, or learn why it is not? (I think it should be.) |
Reopening to permit this case. |
Thanks @ianlancetaylor ! I have some good examples of code that would be vastly simplified if this were allowed... In https://github.com/purpleidea/mgmt/ ... grep for StructOf. Some recent unmerged patches need to be changed to work around this limitation. |
Hiya, I'd love to be able to push this forward in someway, any recommendations on how I could help? Without it, I'd need to seriously re-architecture some of my code which would be significantly less elegant. Thank you! |
One issue to address is the requirements on unexported fields in the A complexity is recreating the data structure that the compiler creates for an unexported name, but that should be doable. |
@ianlancetaylor Thanks Ian! I feel like if you're using this particular feature, you're implementing a language on top of golang or similar, and you might not necessarily care about PkgPath, although I'm not sure what the internal implications of it are. Anything I can do to help here? I can golang, but I don't know the internals of your compiler very well. |
An unexported field requires a PkgPath. In effect the PkgPath is part of the name of the field. The language specifies that an unexported name from one package is never the same as an unexported name from a different package, even if the names are the same identifier. This is implemented using the PkgPath. Working on this issue doesn't require touching the compiler at all. Everything can be done in the reflect package. Look closely at how the reflect package handles the |
Bug or not?
|
@dotaheor I do not see the output mentioned in the comments. I see
|
@ianlancetaylor It looks your output is for tip. So will this be fixed in Go 1.15? |
My output is for tip which will become 1.14. I'm sorry, I don't understand what is broken. You said above "Bug or not?" and then showed a program that does not produce the output that the comments suggest. I don't know whether there is a bug or where it may be. Can you tell us precisely what you expect to see and precisely what you do see? Thanks. |
I mean it looks like a bug if the go1.14beta1 output is the same as go1.14. |
Can you tell us precisely what you expect to see from this program? |
Nothing, I just need to verify whether or not there is a bug in go1.14beta1. |
I don't know if you are expecting any answer from me. |
Do I still need to file a separated issue for this? |
I'm sorry, I have no idea what "this" means, since you haven't answered any of my questions. |
"This" means the program in #25401 (comment) |
We have not yet made the Go 1.14 release branch (though I think we are making it today). Everything that is on tip today will be in Go 1.14. That is what I tried to say above at #25401 (comment). |
OK, thanks for the confirmations. |
Related: #36191 @ianlancetaylor Thanks for fixing this problem. I think this issue can be closed now. |
As mentioned above, we were keeping this issue open specifically to add support for embedded methods. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.2 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
not panic.
What did you see instead?
panic.
If it really should panic, it should be documented.
The text was updated successfully, but these errors were encountered: