Skip to content
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: CanSet returns true for unexported embedded struct fields. #7363

Closed
paranoiacblack opened this issue Feb 19, 2014 · 12 comments
Closed

Comments

@paranoiacblack
Copy link
Contributor

What steps will reproduce the problem?
1. http://play.golang.org/p/P5IJiLANVg


What is the expected output?
No output.

What do you see instead?
panic: B.a is an unexported embedded struct field

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Ubuntu 12.04 LTS

Which version are you using?  (run 'go version')
go version go1.2 linux/amd64

Please provide any additional information below.
According to http://golang.org/pkg/reflect/#Value.CanSet, "A Value can be changed
only if it is addressable and was not obtained by the use of unexported struct
fields." The first clause holds in the example, but the current behavior violates
the second clause.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.3.

@paranoiacblack
Copy link
Contributor Author

Comment 2:

This issue was closed by revision a8a7f18.

Status changed to Fixed.

@rsc
Copy link
Contributor

rsc commented Apr 11, 2014

Comment 3:

I am going to send out a CL to roll back this fix. It is causing too much subtlety to
resolve in 1.3.

Labels changed: added release-go1.4, removed release-go1.3.

Status changed to Accepted.

@gopherbot
Copy link

Comment 4:

CL https://golang.org/cl/85580046 mentions this issue.

@gopherbot
Copy link

Comment 5:

CL https://golang.org/cl/85580046 mentions this issue.

@rsc
Copy link
Contributor

rsc commented Apr 14, 2014

Comment 6:

This issue was closed by revision c48db9a.

Status changed to Fixed.

@rsc
Copy link
Contributor

rsc commented Apr 14, 2014

Comment 7:

Actually it was reopened.

Status changed to Accepted.

@gopherbot
Copy link

Comment 8:

CL https://golang.org/cl/91010047 mentions this issue.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 10:

Labels changed: added release-go1.5, removed release-go1.4.

@rsc
Copy link
Contributor

rsc commented Jul 15, 2015

@mpvl has a plan!

@rsc rsc assigned mpvl Jul 15, 2015
@rsc rsc modified the milestones: Go1.6Early, Go1.5 Jul 15, 2015
@mpvl mpvl added the Started label Aug 26, 2015
@gopherbot
Copy link

CL https://golang.org/cl/14010 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/14085 mentions this issue.

mpvl added a commit that referenced this issue Oct 26, 2015
This CL changes reflect to allow access to exported fields and
methods in unexported embedded structs for gccgo and after gc
has been adjusted to disallow access to embedded unexported structs.

Adresses #12367, #7363, #11007, and #7247.

Change-Id: If80536eab35abcd25300d8ddc2d27d5c42d7e78e
Reviewed-on: https://go-review.googlesource.com/14010
Reviewed-by: Russ Cox <rsc@golang.org>
@mpvl mpvl closed this as completed in afe9837 Oct 26, 2015
@golang golang locked and limited conversation to collaborators Oct 26, 2016
@rsc rsc unassigned mpvl Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants