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: regressed and non-informative error messages when wrong arguments/counts are passed into a function call #48835

Closed
odeke-em opened this issue Oct 7, 2021 · 3 comments
Labels
okay-after-beta1 release-blocker
Milestone

Comments

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 7, 2021

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

GoTip at 6f74ed0 aka Go1.18

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)? Not Applicable

What did you do?

Ran this program https://play.golang.org/p/Md3pUBvDKk8 or inlined below

package main

func bar(_ int) {
}

func baz(_, _ int, _ string) {
}

func main() {
	bar()
	baz("a", "b", 10, 20)
}

What did you expect to see?

./main.go:10:5: not enough arguments in call to bar
	have ()
	want (int)
./main.go:11:5: too many arguments in call to baz
	have (string, string, number, number)
	want (int, int, string)

What did you see instead?

./main.go:10:2: not enough arguments in call to bar
./main.go:11:20: too many arguments in call to baz

This is a regression from Go1.8 and it is unique in the upcoming Go1.18; I understand there have been compiler rewrites but just a count of arguments takes us back to square 0 where we were, yet we had worked on improving the user experience of these messages. I had gotten feedback from users at Gophercon 2016 about how the change that we implemented would improve life for them.

Kindly cc-ing @mdempsky @griesemer

@odeke-em odeke-em added this to the Go1.18 milestone Oct 7, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 7, 2021

Change https://golang.org/cl/354490 mentions this issue: cmd/compile/internal/types2: return prescriptive message for mismatch call arguments

@odeke-em odeke-em self-assigned this Oct 7, 2021
@griesemer griesemer self-assigned this Oct 21, 2021
@griesemer griesemer added the okay-after-beta1 label Oct 27, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 17, 2021

Change https://golang.org/cl/364874 mentions this issue: cmd/compile/internal/types2: report types for mismatched call and return statements

@gopherbot
Copy link

@gopherbot gopherbot commented Nov 26, 2021

Change https://golang.org/cl/367196 mentions this issue: go/types: report types for mismatched call and return statements

gopherbot pushed a commit that referenced this issue Nov 29, 2021
This is a port of CL 364874 from types2 to go/types with various
adjustments:

- the error position for "not enough arguments" in calls is the
  closing ) rather than the position of the last provided argument

- the ERROR comments in tests are positioned accordingly

- the reg. expression for matching error strings accepts newlines
  for the . pattern (added s flag)

For #48834.
For #48835.

Change-Id: I64362ecf605bcf9d89b8dc121432e0131bd5da1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/367196
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
okay-after-beta1 release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants