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

mdempsky opened this issue Dec 26, 2020 · 2 comments


Copy link

@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
@mdempsky mdempsky self-assigned this Dec 26, 2020
Copy link

@gopherbot gopherbot commented Dec 26, 2020

Change 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
Run-TryBot: Matthew Dempsky <>
TryBot-Result: Go Bot <>
Reviewed-by: Robert Griesemer <>
Trust: Robert Griesemer <>
Trust: Matthew Dempsky <>
Copy link
Member Author

@mdempsky mdempsky commented Jan 18, 2021

This is fixed on dev.regabi.


@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
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants