Navigation Menu

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: error message for missing method on type with another type embedded talks about the embedded type instead #47833

Closed
go101 opened this issue Aug 20, 2021 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@go101
Copy link

go101 commented Aug 20, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

type T0 struct {
	x int
}

func (T0) M0() {}

type T2 struct {
	T0
}

type Q *T2

var q Q

func main() {
	q.M0()
}

What did you expect to see?

q.M0 undefined (type Q has no field or method M0)

What did you see instead?

q.T0.M0 undefined (type T0 has no field or method M0, but does have M0)
@mknyszek mknyszek changed the title com/compile: imperfect error message cmd/compile: imperfect error message Aug 20, 2021
@mknyszek mknyszek changed the title cmd/compile: imperfect error message cmd/compile: error message for missing method on type with another type embedded talks about the embedded type instead Aug 20, 2021
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2021
@mknyszek mknyszek added this to the Backlog milestone Aug 20, 2021
@mknyszek
Copy link
Contributor

Is this new in Go 1.17?

CC @griesemer

@cuonglm
Copy link
Member

cuonglm commented Aug 21, 2021

This is fixed at tip 8fff20f

Actually, it was fixed when the compiler switched to use types2. With go1.17, you can do:

$ go1.17 tool compile -G=3 r.go
r.go:18:4: q.M0 undefined (type Q has no field or method M0)

@go101
Copy link
Author

go101 commented Aug 24, 2021

As this is not qualified for backporting, I will close it.

@go101 go101 closed this as completed Aug 24, 2021
@golang golang locked and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants