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: poor error message when invoking method on embedded type #15711

Open
dsymonds opened this Issue May 17, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@dsymonds
Member

dsymonds commented May 17, 2016

Please answer these questions before submitting your issue. Thanks!

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

go1.6.2

  1. What operating system and processor architecture are you using (go env)?

The playground

  1. What did you do?

https://play.golang.org/p/hsjwmQwtsb

Relevant snippet:

func TestFoo(t *testing.T) {
    t.Fail("what?")
}
  1. What did you expect to see?
prog.go:14: too many arguments in call to t.Fail
  1. What did you see instead?
prog.go:14: too many arguments in call to t.common.Fail

The .common bit is unexpected and an implementation detail. Running godoc testing Fail shows a simple method func (c *T) Fail(), and the fact that testing.T embeds testing.common does not seem useful.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone May 17, 2016

@odeke-em

This comment has been minimized.

Member

odeke-em commented Jan 3, 2017

This bug can now be closed. With Go1.8 +e776975, we'll now have a nice message talking about t.common.Fail failing instead of just t.Fail, and that was even fixed in Go1.7
screen shot 2017-01-03 at 1 28 12 am

$ go run main.go 
# command-line-arguments
./main.go:14: too many arguments in call to t.common.Fail
	have (string)
	want ()

The too many arguments improved message was implemented in https://go-review.googlesource.com/25156.

I'll let @bradfitz close it so that we can properly triage and note it as a Go1.7/8 fixed bug.

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Jan 3, 2017

I don't think tracking setting the milestone of a closed bug to a closed milestone makes much difference. Closing this issue.

@dsymonds

This comment has been minimized.

Member

dsymonds commented Jan 3, 2017

Sorry, this isn't fixed. My complaint wasn't about the "too many arguments" part. It was about the error referring to the unexported embedded type.

$ go version
go version devel +d698e614a2 Tue Jan 3 19:23:23 2017 +0000 linux/amd64
$ go test
...
./x_test.go:6: too many arguments in call to t.common.Fail
        have (string)
        want ()

That t.common.Fail is the problematic part. My code doesn't (and can't) refer to t.common.

@dsymonds dsymonds reopened this Jan 3, 2017

@odeke-em

This comment has been minimized.

Member

odeke-em commented Jan 3, 2017

Am sorry about that @dsymonds and @ianlancetaylor, I totally misunderstood that issue, that 1AM clarity. Yap your issue still stands.

@ALTree ALTree changed the title from cmd/compile: Poor error message when invoking method on embedded type to cmd/compile: poor error message when invoking method on embedded type Sep 22, 2018

@ALTree ALTree added the NeedsFix label Sep 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment