Skip to content

go/ast: clarify when Ident.Obj is nil and how to find the ident's ObjΒ #48141

@cuonglm

Description

@cuonglm

The go/ast.Ident is declared as:

type Ident struct {
	NamePos token.Pos // identifier position
	Name    string    // identifier name
	Obj     *Object   // denoted object; or nil
}

Unfortunately, the doc is not much helpful, since when there's no description/example about when Ident.Obj is nil, and how to resolve it.

It's better if we add more documentation to describe this situation.

cc @griesemer @findleyr @mdempsky @timothy-king


For more context, I end up filing this issue after getting the review from @timothy-king in CL 347089. The root cause of that issue is the function declaration of an ident and the ident itself are in two separated files of the same package. Thus the Ident.Obj is nil, and I'm looking through all the pass.Files to lookup the ident's Object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions