]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: be more specific in cannot assign errors
authorAlberto Donizetti <alb.donizetti@gmail.com>
Wed, 16 Sep 2020 11:13:50 +0000 (13:13 +0200)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Wed, 16 Sep 2020 20:04:58 +0000 (20:04 +0000)
commit7ee35cb301eddf4d53e7bb2d5bf0873922d63a6e
tree07fb78617a9a03ca21cec914efb7d851629be3cf
parent10dfb1dd3d1d26122cf18f29468ec17eb7222c3f
cmd/compile: be more specific in cannot assign errors

"cannot assign to" compiler errors are very laconic: they never
explain why the lhs cannot be assigned to (with one exception, when
assigning to a struct field in a map).

This change makes them a little more specific, in two more cases: when
assigning to a string, or to a const; by giving a very brief reason
why the lhs cannot be assigned to.

Change-Id: I244cca7fc3c3814e00e0ccadeec62f747c293979
Reviewed-on: https://go-review.googlesource.com/c/go/+/255199
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/typecheck.go
test/cannotassign.go [new file with mode: 0644]