]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, go/types: omit needless word in error message
authorRuss Cox <rsc@golang.org>
Tue, 24 May 2016 06:52:31 +0000 (02:52 -0400)
committerDavid Chase <drchase@google.com>
Tue, 24 May 2016 15:07:16 +0000 (15:07 +0000)
CL 21462 and CL 21463 made this message say explicitly that the problem
was a struct field in a map, but the word "directly" is unnecessary,
sounds wrong, and makes the error long.

Change-Id: I2fb68cdaeb8bd94776b8022cf3eae751919ccf6f
Reviewed-on: https://go-review.googlesource.com/23373
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/typecheck.go
src/go/types/assignments.go
src/go/types/testdata/stmt0.src
test/fixedbugs/issue13779.go

index 5c23d08cf36cccb0cb1813e6bbd289153c227e72..ffd4afcc01137e42edd07f79110582dc5e6d8c2f 100644 (file)
@@ -3153,7 +3153,7 @@ func checkassign(stmt *Node, n *Node) {
        }
 
        if n.Op == ODOT && n.Left.Op == OINDEXMAP {
-               Yyerror("cannot directly assign to struct field %v in map", n)
+               Yyerror("cannot assign to struct field %v in map", n)
                return
        }
 
index c7564bcf85d355772a9ec514eb214cf86a70fe66..6ebf3b5eab0745ae80d4475c1b26db780b3b8b6d 100644 (file)
@@ -183,7 +183,7 @@ func (check *Checker) assignVar(lhs ast.Expr, x *operand) Type {
                        var op operand
                        check.expr(&op, sel.X)
                        if op.mode == mapindex {
-                               check.errorf(z.pos(), "cannot directly assign to struct field %s in map", ExprString(z.expr))
+                               check.errorf(z.pos(), "cannot assign to struct field %s in map", ExprString(z.expr))
                                return nil
                        }
                }
index ac32ed7ba92f3297dbd8350b56b24d51b79a9c00..0c727c3dd011a97d003104126dc44116d2192ee8 100644 (file)
@@ -137,7 +137,7 @@ func issue6487() {
 
        type M map[string]S
        var m M
-       m /* ERROR "cannot directly assign to struct field" */ ["foo"].x = 0
+       m /* ERROR "cannot assign to struct field" */ ["foo"].x = 0
        _ = &( /* ERROR "cannot take address" */ m["foo"].x)
        _ = &m /* ERROR "cannot take address" */ ["foo"].x
 }
index 94cf9c68de0fe9bfb3bd6f79949fd57047a2a925..b18577c152849675078f6f8a4833c75e3507235e 100644 (file)
@@ -11,5 +11,5 @@ package main
 func main() {
        type person struct{ age, weight, height int }
        students := map[string]person{"sally": person{12, 50, 32}}
-       students["sally"].age = 3 // ERROR "cannot directly assign to struct field .* in map"
+       students["sally"].age = 3 // ERROR "cannot assign to struct field .* in map"
 }