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/ast: Decl field for variables declared in range clause does not point to range statement #5241

Closed
griesemer opened this issue Apr 8, 2013 · 9 comments
Assignees

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Apr 8, 2013

See:

http://play.golang.org/p/bi9UkUc8Uq

Michael Fromberger points out that the iteration variables' declaration nodes pointed to
by their respective ast.Objects is the "pseudo-assignment" inside the range
clause, but that it should be the range statement itself (since the assignment is never
seen in the AST).
@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Apr 8, 2013

Comment 1:

Per Michael Fromberger:
"Yes, I think the RangeStmt would be the correct place. In general, I would argue the
declaration should always be a node that will be visited in an ordinary traversal of the
AST.*  So, I would also be okay with having RangeStmt contain an AssignStmt node as one
of its children, and having that be the declaration for the identifiers (when
appropriate)."
@rsc
Copy link
Contributor

@rsc rsc commented Jul 30, 2013

Comment 2:

Labels changed: added priority-later, go1.2maybe, removed priority-triage.

@rsc
Copy link
Contributor

@rsc rsc commented Jul 30, 2013

Comment 3:

Labels changed: added feature.

@robpike
Copy link
Contributor

@robpike robpike commented Aug 29, 2013

Comment 4:

Not for 1.2.

Labels changed: removed go1.2maybe.

@rsc
Copy link
Contributor

@rsc rsc commented Nov 27, 2013

Comment 5:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

@rsc rsc commented Nov 27, 2013

Comment 6:

Labels changed: removed feature.

@rsc
Copy link
Contributor

@rsc rsc commented Dec 4, 2013

Comment 7:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

@rsc rsc commented Dec 4, 2013

Comment 8:

Labels changed: added repo-main.

@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Feb 27, 2014

Comment 9:

The preferred mechanism to obtain the correct objects for identifiers is to use go/types
now: For each identifier, go/type will report the corresponding types.Object (defs,
uses, coming shortly). A reverse mapping (object -> defining identifier) is easily
computed from that. The defining identifier appears in the AST and is not synthetic.

Status changed to Unfortunate.

@griesemer griesemer self-assigned this Feb 27, 2014
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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
4 participants
You can’t perform that action at this time.