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

cmd/compile/internal/types2: when constructing MethodExpr types, reuse receiver Var info #46209

Open
mdempsky opened this issue May 17, 2021 · 2 comments
Assignees
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 17, 2021

In Checker.selector, when types2 constructs the Signature to represent a method expression, it creates a receiver variable with no position, the current package, and "_" as the variable name. I think it would be better to reuse this information from sig.recv for consistency with the rest of the parameters.

One catch appears to be that sig.recv may be nil at least in some invalid source files (e.g., the straightforward change to use it led to crashes in some of the types2 regress tests). I expect though that no valid code would have this problem (otherwise the rest of the parameters would be wrong too). Maybe if sig.recv is nil, we should just bail with goto Error?

/cc @griesemer @findleyr

@mdempsky mdempsky added this to the Go1.18 milestone May 17, 2021
@mdempsky mdempsky self-assigned this May 17, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented May 17, 2021

Change https://golang.org/cl/320489 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: better recv Var for method expressions

gopherbot pushed a commit that referenced this issue May 19, 2021
…hod expressions

When synthesizing the Signature to represent a method expression, keep
as much of the original parameter as possible, substituting only the
receiver type.

Fixes #46209.

Change-Id: Ic4531820ae7d203bb0ba25a985f72d219b4aa25f
Reviewed-on: https://go-review.googlesource.com/c/go/+/320489
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 3, 2021

Change https://golang.org/cl/324733 mentions this issue: go/types: better recv Var for method expressions

gopherbot pushed a commit that referenced this issue Jun 4, 2021
This is a port of CL 320489 to go/types, adjusted to be consistent about
named/unnamed parameters. TestEvalPos was failing without this addition.

For #46209

Change-Id: Icdf86e84ebce8ccdb7846a63b5605e360e2b8781
Reviewed-on: https://go-review.googlesource.com/c/go/+/324733
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants