-
Notifications
You must be signed in to change notification settings - Fork 563
Open
Open
Copy link
Description
Background
Go 1.25 added semantic categories for variables in go/types.
In upstream Go type checking, method receivers are created as RecvVar.
go/types/signature.gocreates receiver withRecvVargo/types/object.godocumentsNewParamandSetKindgo/typestest expectsrecv: 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(...).
cl/func_type_and_var.go: receiver built viactx.pkg.NewParam(...)cl/compile.go: syntheticthisbuilt viatypes.NewParam(...)
This makes receiver vars indistinguishable from ordinary parameters through Var.Kind.
Proposal
For Go 1.25+ builds in XGo:
- Set receiver vars to
types.RecvVarimmediately after creation - Set result vars to
types.ResultVarwhere 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.RecvVarx.Kind() == types.ParamVary.Kind() == types.ResultVar
Also:
- Existing tests continue to pass.
- Add focused tests for receiver, parameter, and result kind classification.
Reactions are currently unavailable