summaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2017-06-27 12:58:32 -0700
committerMatthew Dempsky <mdempsky@google.com>2017-06-27 20:29:33 +0000
commitf62c608abb7a2fd44f634b58cf24aa0d2e1d42d4 (patch)
tree2907cf3fd28dafa0be4ff61e4665f84992b0242e /src/cmd/compile
parentae238688d2813e83f16050408487ea34ba1c2fff (diff)
downloadgo-git-f62c608abb7a2fd44f634b58cf24aa0d2e1d42d4.tar.gz
cmd/compile: suppress errors after "cannot assign to X"
If the LHS is unassignable, there's no point in trying to make sure the RHS can be assigned to it or making sure they're realizable types. This is consistent with go/types. In particular, this prevents "1 = 2" from causing a panic when "1" still ends up with the type "untyped int", which is not realizable. Fixes #20813. Change-Id: I4710bdaac2e375ef12ec29b888b8ac84fb640e56 Reviewed-on: https://go-review.googlesource.com/46835 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/gc/typecheck.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go
index bff278b7ae..795bdcdd35 100644
--- a/src/cmd/compile/internal/gc/typecheck.go
+++ b/src/cmd/compile/internal/gc/typecheck.go
@@ -3288,10 +3288,10 @@ func checkassign(stmt *Node, n *Node) {
if n.Op == ODOT && n.Left.Op == OINDEXMAP {
yyerror("cannot assign to struct field %v in map", n)
- return
+ } else {
+ yyerror("cannot assign to %v", n)
}
-
- yyerror("cannot assign to %v", n)
+ n.Type = nil
}
func checkassignlist(stmt *Node, l Nodes) {