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
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
1
>>> c
2
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.
The text was updated successfully, but these errors were encountered:
ALTree
added
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Sep 10, 2018
I'm ok with making the error message more specific in case of a return statement. Not urgent.
griesemer
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
labels
Sep 12, 2018
This is a followup to #26616 which changed error message for this case:
from
multiple-value bar.ReadString() in single-value context
to1 variable but 2 values
.In Python, if function returns multiple arguments (a tuple), it is completely okay to assign it to one variable:
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.The text was updated successfully, but these errors were encountered: