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: "1 variable but %d values" to "1 variable but %d return values" #27595

techtonik opened this issue Sep 10, 2018 · 3 comments


None yet
5 participants
Copy link

commented Sep 10, 2018

This is a followup to #26616 which changed error message for this case:

bar := bufio.NewReader(...)
line := bar.ReadString()

from multiple-value bar.ReadString() in single-value context to 1 variable but 2 values.

In Python, if function returns multiple arguments (a tuple), it is completely okay to assign it to one variable:

>>> def xxx():
...   return 1,2
>>> a = xxx()
>>> b, c = xxx()
>>> a
(1, 2)
>>> b
>>> c

Therefore if a Python coder like me is reading the Go code, it is not completely obvious what is going on, which was the reason to fill #26616. The error message that fixes #26616 is good, but could be improved to include return values for explicit context that the error cause is in return type of the function and not in the assignment statement.

@ALTree ALTree added this to the Go1.12 milestone Sep 10, 2018


This comment has been minimized.

Copy link

commented Sep 12, 2018


This comment has been minimized.

Copy link

commented Sep 12, 2018

I'm ok with making the error message more specific in case of a return statement. Not urgent.

@griesemer griesemer added NeedsFix and removed NeedsDecision labels Sep 12, 2018

@griesemer griesemer modified the milestones: Go1.12, Unplanned Sep 12, 2018


This comment has been minimized.

Copy link

commented Sep 15, 2018

Change mentions this issue: cmd/compile: using more specific error message for assignment mismatch

@gopherbot gopherbot closed this in ae9c822 Sep 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.