Skip to content

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

Closed

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)

Activity

  1. networkimprov commented on Dec 5, 2020

    @networkimprov

    cc @mdempsky @griesemer

    Seems overlooked by triage?

  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Dec 7, 2020
  3. added this to the Go1.17 milestone on Dec 7, 2020
  4. self-assigned this
    on Dec 7, 2020
  5. 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[/+] on Jan 18, 2021
  6. modified the milestones: Go1.17, Go1.18 on Apr 28, 2021
  7. ianlancetaylor commented on Nov 16, 2021

    @ianlancetaylor
    Contributor

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

  8. griesemer commented on Nov 17, 2021

    @griesemer
    Contributor

    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.

  9. gopherbot commented on Dec 21, 2021

    @gopherbot
    Contributor

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

  10. odeke-em commented on Dec 21, 2021

    @odeke-em
    Member

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

  11. self-assigned this
    on Jan 6, 2022
  12. added a commit that references this issue on Jun 21, 2022
    5fdbf03
  13. locked and limited conversation to collaborators on Jun 23, 2023
  14. added a commit that references this issue on Sep 19, 2024
    8070e70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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