diff options
| author | Emmanuel Odeke <emm.odeke@gmail.com> | 2018-02-10 20:10:26 -0800 |
|---|---|---|
| committer | Emmanuel Odeke <emm.odeke@gmail.com> | 2018-02-13 19:42:15 +0000 |
| commit | 25d22d9abae4345c24cd2ae7f26de1846888faa4 (patch) | |
| tree | 0c5050b56306933b35a5414741b15de6a4192f24 /src | |
| parent | dc3bef36354c7977cfd9e4459e1e6f31bc8624a6 (diff) | |
| download | go-25d22d9abae4345c24cd2ae7f26de1846888faa4.tar.xz | |
cmd/compile: report the struct type in invalid number of initializer values
Fixes #23732
Disambiguate "too few" or "too many" values in struct
initializer messages by reporting the name of the literal.
After:
issue23732.go:27:3: too few values in Foo literal
issue23732.go:34:12: too many values in Bar literal
issue23732.go:40:6: too few values in Foo literal
issue23732.go:40:12: too many values in Bar literal
Change-Id: Ieca37298441d907ac78ffe960c5ab55741a362ef
Reviewed-on: https://go-review.googlesource.com/93277
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/gc/typecheck.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 5285cb22d9..0161f26890 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -3030,7 +3030,7 @@ func typecheckcomplit(n *Node) *Node { ls[i] = n1 if i >= t.NumFields() { if !errored { - yyerror("too many values in struct initializer") + yyerror("too many values in %v", n) errored = true } continue @@ -3048,7 +3048,7 @@ func typecheckcomplit(n *Node) *Node { ls[i] = n1 } if len(ls) < t.NumFields() { - yyerror("too few values in struct initializer") + yyerror("too few values in %v", n) } } else { hash := make(map[string]bool) |
