Skip to content

cmd/compile: improve "have X want Y" error with additional file and line information #42841

@raspi

Description

@raspi

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

go1.15.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

type S interface {
	DoSomething() (int, error)
}

type myS struct{}

func (s myS) DoSomething() (string, error) {
	return ``, nil
}

func main() {
	var _ S = &myS{}
}

What did you expect to see?

Show also line information (foo.go:123:57) for have line. The implementation might be in completely different file. In modern IDEs you simply can click the file information line to navigate to referenced file and line quickly.

want could also have line information to referenced interface definition line?

./prog.go:14:6: cannot use &myS literal (type *myS) as type S in assignment:
	*myS does not implement S (wrong type for DoSomething method)
		have DoSomething() (string, error) at ./prog.go:9:28
		want DoSomething() (int, error)

What did you see instead?

./prog.go:14:6: cannot use &myS literal (type *myS) as type S in assignment:
	*myS does not implement S (wrong type for DoSomething method)
		have DoSomething() (string, error)
		want DoSomething() (int, error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions