Skip to content

proposal: preserve go/types.Var.Kind semantics for receiver and result vars on Go 1.25+ #2663

@aofei

Description

@aofei

Background

Go 1.25 added semantic categories for variables in go/types.

In upstream Go type checking, method receivers are created as RecvVar.

Current behavior in XGo

In XGo compile paths, receiver and some result-like vars are created through NewParam(...) and are not relabeled with SetKind(...).

This makes receiver vars indistinguishable from ordinary parameters through Var.Kind.

Proposal

For Go 1.25+ builds in XGo:

  • Set receiver vars to types.RecvVar immediately after creation
  • Set result vars to types.ResultVar where applicable
  • Keep ordinary parameters as types.ParamVar

No source-position or naming behavior change is required.

Acceptance criteria

Given func (r *T) M(x int) (y int) {}:

  • r.Kind() == types.RecvVar
  • x.Kind() == types.ParamVar
  • y.Kind() == types.ResultVar

Also:

  • Existing tests continue to pass.
  • Add focused tests for receiver, parameter, and result kind classification.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions