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

Comments

@go101
Copy link

@go101 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 this to the Backlog milestone Aug 20, 2021
@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Aug 20, 2021

Is this new in Go 1.17?

CC @griesemer

Loading

@cuonglm
Copy link
Member

@cuonglm 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)

Loading

@go101
Copy link
Author

@go101 go101 commented Aug 24, 2021

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

Loading

@go101 go101 closed this Aug 24, 2021
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
3 participants