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: improve "have X want Y" error with additional file and line information #42841

Closed
raspi opened this issue Nov 26, 2020 · 5 comments
Closed
Labels
NeedsInvestigation
Milestone

Comments

@raspi
Copy link

@raspi raspi commented Nov 26, 2020

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)
@networkimprov
Copy link

@networkimprov networkimprov commented Dec 5, 2020

cc @mdempsky @griesemer

Seems overlooked by triage?

@griesemer griesemer added the NeedsInvestigation label Dec 7, 2020
@griesemer griesemer added this to the Go1.17 milestone Dec 7, 2020
@griesemer griesemer self-assigned this Dec 7, 2020
@mdempsky mdempsky changed the title Improve "have X want Y" error with additional file and line information cmd/compile: improve "have X want Y" error with additional file and line information Jan 18, 2021
@griesemer griesemer removed this from the Go1.17 milestone Apr 28, 2021
@griesemer griesemer added this to the Go1.18 milestone Apr 28, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 16, 2021

@griesemer Should this stay in the Go1.18 milestone or should we move it to Backlog?

@griesemer
Copy link
Contributor

@griesemer griesemer commented Nov 17, 2021

I think this is either done or mostly done (or pending CL). We should keep this for 1.18; I will take care of it.

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 21, 2021

Change https://golang.org/cl/373634 mentions this issue: cmd/compile/types2: add position failed failed interface satisfaction error

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Dec 21, 2021

I've mailed a CL for this per https://golang.org/cl/373634.

@odeke-em odeke-em self-assigned this Jan 6, 2022
jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
…face satisfaction

With this change, we shall now see:

    *myS does not implement S (wrong type for DoSomething method)
        have DoSomething() (string, error) at ./main.go:9:14
	want DoSomething() (int, error)

instead of previously:

    *myS does not implement S (wrong type for DoSomething method)
        have DoSomething() (string, error)
	want DoSomething() (int, error)

Fixes golang#42841
Fixes golang#45813

Change-Id: I66990929e39b0d36f2e91da0d92f60586a9b84e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/373634
Trust: Robert Findley <rfindley@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

6 participants