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: awkward wording of count mismatch error #22159

Closed
rsc opened this issue Oct 5, 2017 · 12 comments
Closed

cmd/compile: awkward wording of count mismatch error #22159

rsc opened this issue Oct 5, 2017 · 12 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Oct 5, 2017

Error from cmd/compile:

internal/load/pkg.go:1112:16: cannot assign 3 values to 2 variables
internal/load/pkg.go:1536:21: cannot assign 3 values to 2 variables

This is a correct statement (my code says x, y := f() where f has 3 results),
but the numbers appear reversed from what's in the source code (2 variables = 3 values). Trying to keep the same left-to-right flow is part of the reason the old message said something like "assignment mismatch: 2 = 3". I appreciate that the old message is super-cryptic, and the new message is much clearer, but can you find some way to reword it so that the number 2 appears before the number 3?

/cc @griesemer @mdempsky

@rsc rsc added this to the Go1.10 milestone Oct 5, 2017
@ianlancetaylor
Copy link
Contributor

cannot set 2 variables to 3 values

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 5, 2017
@griesemer griesemer self-assigned this Oct 5, 2017
@mdempsky
Copy link
Member

mdempsky commented Oct 5, 2017

It looks like it used to say want 1 values, got 2: 73a44f0.

cannot set 2 variables to 3 values sounds clumsy to me because I expect to to refer to the receiver of the assignment.

Maybe cannot assign 2 variables with 3 values?

@griesemer
Copy link
Contributor

assignment mismatch: 2 variables but 3 values

That goes back to the original but at least doesn't use the cryptic 2 = 3.

@ghost
Copy link

ghost commented Oct 5, 2017

to 2 variables 3 values cannot be assigned

@ianlancetaylor
Copy link
Contributor

to 2 variables 3 values assign you can not

@randall77
Copy link
Contributor

randall77 commented Oct 5, 2017 via email

@mdempsky
Copy link
Member

mdempsky commented Oct 5, 2017

@randall77 Sadly, that wording still puts the number of variables after the number of values (and the number of values + 1, and the number of values - 1), so it doesn't address @rsc's issue. 😭

@jolan
Copy link

jolan commented Oct 5, 2017

Maybe change this to multi? I was just looking at the go/types version of this. It looks like go/types was changed to match cmd/compile:

https://go-review.googlesource.com/c/go/+/38315

Bikeshedding: I thought assignment count mismatch (%d vs %d) was fine. Maybe != instead of vs.

@griesemer
Copy link
Contributor

Es ist verboten 2 Variablen 3 Werte zuzuweisen.

@golang golang locked and limited conversation to collaborators Oct 5, 2017
@mdempsky
Copy link
Member

mdempsky commented Oct 5, 2017

sǝןqɐıɹɐʌ 2 oʇ sǝnןɐʌ 3 ubıssɐ ʇouuɐɔ

@gopherbot
Copy link

Change https://golang.org/cl/68690 mentions this issue: cmd/compile: better error message for assignment mismatches

@griesemer
Copy link
Contributor

The above change was submitted and properly attributed this issue. Not sure why this was not automatically closed. Closing now.

gopherbot pushed a commit that referenced this issue Dec 6, 2017
Keep left-to-right order when referring to the number of
variables and values involved.

Fixes #22159.

Change-Id: Iccca12d3222f9d5e049939a9ccec07513c393faa
Reviewed-on: https://go-review.googlesource.com/68690
Reviewed-by: Russ Cox <rsc@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants