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
Assignees

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Dec 26, 2020

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

@gopherbot gopherbot commented Dec 26, 2020

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

Loading

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

@mdempsky mdempsky commented Jan 18, 2021

This is fixed on dev.regabi.

Loading

@mdempsky mdempsky closed this Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants