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

go/types: specify Object.Parent more precisely #14647

Closed
alandonovan opened this issue Mar 4, 2016 · 1 comment
Closed

go/types: specify Object.Parent more precisely #14647

alandonovan opened this issue Mar 4, 2016 · 1 comment
Assignees
Milestone

Comments

@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Mar 4, 2016

The Parent of an Object representing an interface method or struct field is nil, which is a surprise: you might expect its parent to be the enclosing file or local scope that defines the environment in which the object's declaration is resolved. It is also undocumented.

Given that nothing was specified, I would not be averse to changing the behavior, though it would certainly cause some existing programs to break and may violate the spirit of the compatibility rules.

In any case we should clearly document the behavior.

@bradfitz bradfitz added this to the Go1.7 milestone Apr 10, 2016
@rsc rsc added this to the Go1.8 milestone May 18, 2016
@rsc rsc removed this from the Go1.7 milestone May 18, 2016
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 18, 2016

Struct fields, type-associated and interface methods are not declared in a block scope, which is what parent scopes refer to. They are conceivably declared in a type-specific "scope" but that's just not how types.Scopes are used. Hence those objects' parent scopes are nil.

I don't think it makes sense to change this now. I'll document it.

Loading

@gopherbot gopherbot closed this in 89d085d Aug 18, 2016
@golang golang locked and limited conversation to collaborators Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants