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 error message when a method expression references ambiguous method name #14321

Closed
momchil-velikov opened this issue Feb 13, 2016 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@momchil-velikov
Copy link
Contributor

In the following program

package main
type A struct {}
func (A) F() {}
type B struct {}
func (B) F() {}
type C struct {
    A
    B
}
var _ = C.F
func main() {}

the go compiler issues error message C.F undefined (type C has no method F), whereas the type C in fact has a method F, even two of them :)

gccgo and gotype correctly report ambiguous method error.

go version devel +76cb265 Sat Feb 13 06:46:47 2016 +0000 linux/amd64

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Feb 13, 2016
@minux
Copy link
Member

minux commented Feb 14, 2016 via email

@momchil-velikov
Copy link
Contributor Author

Right. I see now. Thank you.

@rsc rsc modified the milestones: Go1.8, Go1.7 May 17, 2016
@odeke-em
Copy link
Member

odeke-em commented Oct 5, 2016

@minux after @momchil-velikov's agreement of your explanation, do you think this issue should be closed?

@griesemer
Copy link
Contributor

This is not about whether gc has a bug or not - this is about improving the error message. gc may be technically correct, but a typical user not fluent in the fine points of the spec by heart (really, all of us), is going to scratch his or her head.

I think remarking on the ambiguity of the selector in the error message is helpful.

Please keep this open. It's not urgent, though.

@griesemer griesemer modified the milestones: Go1.8Maybe, Go1.8 Oct 5, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@rsc
Copy link
Contributor

rsc commented Oct 20, 2016

It would be nice to say '(type C has ambiguous method F)' instead, in this case.

@rsc rsc modified the milestones: Go1.9, Go1.8Maybe Oct 20, 2016
@griesemer griesemer self-assigned this Oct 20, 2016
@gopherbot
Copy link

CL https://golang.org/cl/41853 mentions this issue.

@bradfitz bradfitz modified the milestones: Go1.10, Go1.9 Jun 15, 2017
@mdempsky mdempsky modified the milestones: Go1.10, Go1.11 Nov 30, 2017
@gopherbot
Copy link

Change https://golang.org/cl/106119 mentions this issue: cmd/compile: better error message when referring to ambiguous method/field

@golang golang locked and limited conversation to collaborators Apr 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

10 participants