Skip to content

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

@stamblerre

Description

@stamblerre

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions