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: change "multiple-value .. in single-value context" error message to be consistent with >1 case #26616
Comments
It looks like 1 vs >1 is a special case. For example, this code:
results in "assignment mismatch: 2 variables but 3 values", which is close to what you expect. |
I would still insist on |
The error message is the same vein of how we write failure messages in test - I am not sure why the single-value context is considered a special case. /cc @josharian @mdempsky |
Regardless of whether the 1 vs >1 special case is changed, it sounds like you prefer an alt error message for the general case. I have a couple concerns with your approach:
|
I think it's very unlikely we'd adopt the wording I'm sympathetic to changing the error message to If anyone wants to dig into this, look at typecheckas and typecheckas2 in typecheck.go. In particular, Efnstruct (to suppress the "multi-value in single-value context" error) and IsFuncArgStruct (to distinguish a multi-value expression). |
Change https://golang.org/cl/129065 mentions this issue: |
Change https://golang.org/cl/131280 mentions this issue: |
For ordering it should be
This one is good. I would only specify that these are "2 return values". |
Change https://golang.org/cl/133335 mentions this issue: |
The current wording for As I mentioned on the CL, I'm open to discussion about changing both instances to "3 return values" (or more precisely "3 result values," per the Go spec), but let's open a new issue for that. Personally, I think the current wording (as of f7a633a) is unambiguous. |
What version of Go are you using (
go version
)?1.10
What did you do?
What did you expect to see?
What did you see instead?
The expected error text should be more clear for people without a university degree. =)
The text was updated successfully, but these errors were encountered: