]> Cypherpunks repositories - gostls13.git/commit
go/types: better error when assigning to struct field in map
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 2 Apr 2016 15:04:45 +0000 (12:04 -0300)
committerDavid Chase <drchase@google.com>
Mon, 4 Apr 2016 15:10:48 +0000 (15:10 +0000)
commit74c0fea9e8a37ae08d4c08b71d27be94feb3332a
tree0d0915e86f458750c792d8a7446e9ead3ce52080
parentf229e46783a12b7604bf99f0b7329965d5a2b1f6
go/types: better error when assigning to struct field 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>
src/go/types/assignments.go
src/go/types/testdata/stmt0.src