You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
funcfoo() (int, error) {
returnnil
}
funcmain() {}
What did you expect to see?
./main.go:4:2: not enough arguments to return
have (nil)
want (int, error)
What did you see instead?
./main.go:4:2: wrong number of return values (want 2, got 1)
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. This was one of my first contributions to the compiler driven after getting feedback from users at Gophercon 2016 fixing at least 2 issues #4215 and #6750.
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>
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 ApplicableWhat did you do?
Ran this program https://play.golang.org/p/uUOlQ-99Wx_y or inlined below
What did you expect to see?
./main.go:4:2: not enough arguments to return have (nil) want (int, error)
What did you see instead?
./main.go:4:2: wrong number of return values (want 2, got 1)
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. This was one of my first contributions to the compiler driven after getting feedback from users at Gophercon 2016 fixing at least 2 issues #4215 and #6750.
Kindly cc-ing @mdempsky @griesemer
The text was updated successfully, but these errors were encountered: