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: erroneously allows promoted-method calls on function-scoped declared pointer types #43384

Closed
mdempsky opened this issue Dec 26, 2020 · 2 comments

Comments

@mdempsky
Copy link
Member

cmd/compile erroneously accepts the file below. go/types and gccgo correctly reject it.

package p

type T int

func (T) M() {}

func f() {
	type P *struct{ T }
	var p P
	p.M()
}
@mdempsky mdempsky self-assigned this Dec 26, 2020
@gopherbot
Copy link

Change https://golang.org/cl/280392 mentions this issue: [dev.regabi] cmd/compile: fix defined-pointer method call check

gopherbot pushed a commit that referenced this issue Dec 30, 2020
The compiler has logic to check whether we implicitly dereferenced a
defined pointer while trying to select a method. However, rather than
checking whether there were any implicit dereferences of a defined
pointer, it was finding the innermost dereference/selector expression
and checking whether that was dereferencing a named pointer. Moreover,
it was only checking defined pointer declared in the package block.

This CL restructures the code to match go/types and gccgo's behavior.

Fixes #43384.

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

This is fixed on dev.regabi.

@golang golang locked and limited conversation to collaborators Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants