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

go/types: missing method errors for interfaces should have more detail #38475

Closed
stamblerre opened this issue Apr 15, 2020 · 1 comment
Closed

Comments

@stamblerre
Copy link
Contributor

Given this program:

package main

func main() {}

type iface interface {
	hello(x string) string
}

func h(x iface) {}

type structy struct{}

func (s structy) hello(x string) {}

func _() {
	var x structy
	h(x)
}

The compiler produces the following error message:

./main.go:17:3: cannot use x (type structy) as type iface in argument to h:
	structy does not implement iface (wrong type for hello method)
		have hello(string)
		want hello(string) string

Whereas, go/types produces: cannot use x (variable of type structy) as iface value in argument to h: wrong type for method hello

We should add more detail to the go/types error message.

@gopherbot
Copy link

Change https://golang.org/cl/228457 mentions this issue: go/types: add detail to missing method error messages

@golang golang locked and limited conversation to collaborators Apr 16, 2021
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