aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Odeke <emm.odeke@gmail.com>2016-10-27 21:52:33 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2016-10-29 05:33:14 +0000
commit7b4545653c371be73c660bc87356ec467496dbbf (patch)
tree1ee6277be3a821c9b22968222d3f4435d89419d4 /src
parent894abb5f680c040777f17f9f8ee5a5ab3a03cb94 (diff)
downloadgo-7b4545653c371be73c660bc87356ec467496dbbf.tar.xz
cmd/compile: improve error message for unknown fields in structs
Improves the error message by moving the field name before the body of a struct, in the error message for unknown fields for structs. * Exhibit: Given program: package main import "time" func main() { _ = struct { about string before map[string]uint update map[string]int updateTime time.Time expect map[string]int }{ about: "this one", updates: map[string]int{"gopher": 10}, } } * Before: ./issue17631.go:20: unknown struct { about string; before map[string]uint; update map[string]int; updateTime time.Time; expect map[string]int } field 'updates' in struct literal * After: ./issue17631.go:20: unknown field 'updates' in struct literal of type { about string; before map[string]uint; update map[string]int; updateTime time.Time; expect map[string]int } Fixes #17631 Change-Id: I76842616411b931b5ad7a76bd42860dfde7739f4 Reviewed-on: https://go-review.googlesource.com/32240 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/typecheck.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go
index 94ae32ec2c..1a8056a2a4 100644
--- a/src/cmd/compile/internal/gc/typecheck.go
+++ b/src/cmd/compile/internal/gc/typecheck.go
@@ -3095,7 +3095,7 @@ func typecheckcomplit(n *Node) *Node {
f := lookdot1(nil, l.Sym, t, t.Fields(), 0)
if f == nil {
- yyerror("unknown %v field '%v' in struct literal", t, l.Sym)
+ yyerror("unknown field '%v' in struct literal of type %v", l.Sym, t)
continue
}
fielddup(f.Sym.Name, hash)