summaryrefslogtreecommitdiff
path: root/src/go/types
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-05-04 17:01:53 -0700
committerGopher Robot <gobot@golang.org>2023-05-05 19:07:50 +0000
commit26899ef3ee7cd3d9e663e6f792c93bb411c863db (patch)
tree60df2b4777e48e32c4eb3bf78e8d85dd334d8f9c /src/go/types
parenta5350558e6e2db16bfe09f2ba8104549c6598c46 (diff)
downloadgo-git-26899ef3ee7cd3d9e663e6f792c93bb411c863db.tar.gz
go/types, types2: better error message for bad assignment
If the LHS of an assignment is neither addressable nor a map expression (and not the blank identifier), explicitly say so for a better error message. For #3117. Change-Id: I4bffc35574fe390a0567e89182b23585eb5a90de Reviewed-on: https://go-review.googlesource.com/c/go/+/492875 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/go/types')
-rw-r--r--src/go/types/assignments.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/go/types/assignments.go b/src/go/types/assignments.go
index b0d11dfb82..1ea51142e0 100644
--- a/src/go/types/assignments.go
+++ b/src/go/types/assignments.go
@@ -221,7 +221,7 @@ func (check *Checker) lhsVar(lhs ast.Expr) Type {
return Typ[Invalid]
}
}
- check.errorf(&x, UnassignableOperand, "cannot assign to %s", &x)
+ check.errorf(&x, UnassignableOperand, "cannot assign to %s (neither addressable nor a map index expression)", x.expr)
return Typ[Invalid]
}