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
Currently, I see the error: prog.go:6: cannot assign to students["sally"].age
While the message tells you what went wrong, it doesn't tell you why it is wrong. It causes a programmer to scratch his/her head wondering why this is happening. "Did I misspell the field name?" "Is the map using the wrong type?" etc...
I expect to see something more informative: prog.go:6: cannot directly assign to struct field students["sally"].age in map
Identify this assignment case and instead of the more general error
prog.go:6: cannot assign to students["sally"].age (value of type int)
produce
prog.go:6: cannot directly assign to struct field students["sally"].age in map
that explains why the assignment is not possible. Used ExprString
instead of String of operand since the type of the field is not relevant
to the error.
Updates #13779.
Change-Id: I581251145ae6336ddd181b9ddd77f657c51b5aff
Reviewed-on: https://go-review.googlesource.com/21463
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Using
go1.5
Compile the following code:
Currently, I see the error:
prog.go:6: cannot assign to students["sally"].age
While the message tells you what went wrong, it doesn't tell you why it is wrong. It causes a programmer to scratch his/her head wondering why this is happening. "Did I misspell the field name?" "Is the map using the wrong type?" etc...
I expect to see something more informative:
prog.go:6: cannot directly assign to struct field students["sally"].age in map
This is related to #3117
The text was updated successfully, but these errors were encountered: