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>
}
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
}
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
}
}
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
}
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"
}