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

Comments

Projects
None yet
7 participants
@rsc
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2017

cannot set 2 variables to 3 values

@griesemer griesemer self-assigned this Oct 5, 2017

@mdempsky

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2017

assignment mismatch: 2 variables but 3 values

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

@ghost

This comment has been minimized.

Copy link

commented Oct 5, 2017

to 2 variables 3 values cannot be assigned

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2017

to 2 variables 3 values assign you can not

@randall77

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2017

@mdempsky

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2017

Es ist verboten 2 Variablen 3 Werte zuzuweisen.

@golang golang locked and limited conversation to collaborators Oct 5, 2017

@mdempsky

This comment has been minimized.

Copy link
Member

commented Oct 5, 2017

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

This comment has been minimized.

Copy link

commented Oct 5, 2017

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

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2017

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

@griesemer griesemer closed this Oct 10, 2017

gopherbot pushed a commit that referenced this issue Dec 6, 2017

cmd/compile: better error message for assignment mismatches
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.
You can’t perform that action at this time.