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: error message for disallowed ... actual parameter is confusing #6750

Closed
tbushnell opened this issue Nov 11, 2013 · 7 comments
Closed

Comments

@tbushnell
Copy link

If I have "func foo(nums ...int)", and try a call like this: "foo(1,
[]int{2, 3}...)" the error message is confusing. You get something like this:

prog.go:17: too many arguments in call to printmany

See http://play.golang.org/p/Kmih0YUS0N.

Of course, since the function *does* accept that many arguments, it's not correct. The
error is really more like a type error, or "incorrect number of arguments before
final slice argument" or something like that.
@robpike
Copy link
Contributor

robpike commented Nov 20, 2013

Comment 1:

Well, you gave it two arguments and it only accepts one. That said, the message could
require less special understanding.

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@tbushnell
Copy link
Author

Comment 2:

It only accepts one? There is one formal parameter, but this is an error at the call
site, where it most certainly accepts a larger list of actual parameters. For example, a
call like foo(1, 2) works without a hitch.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 3:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: error message for disallowed ... actual parameter is confusing cmd/compile: error message for disallowed ... actual parameter is confusing Jun 8, 2015
@odeke-em
Copy link
Member

I think when CL https://go-review.googlesource.com/#/c/25156 is merged or if #4215 is fixed, so will this issue be fixed too /cc @josharian.
The result will be something like

$ go run Kmih0YUS0N.go 
# command-line-arguments
./Kmih0YUS0N.go:17: too many arguments in call to printmany, got (untyped number, []int) want (...int)

@odeke-em odeke-em self-assigned this Aug 1, 2016
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Oct 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants