cmd/compile: confusing error if composite literal field is a method

When looking for the field specified in a composite literal, check that
the specified name is actually a field and not a method.

Fixes #29855.

Change-Id: Id77666e846f925907b1eec64213b1d25af8a2466
Reviewed-on: https://go-review.googlesource.com/c/158938
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Michael Fraenkel 2019-01-22 19:10:29 -05:00 committed by Daniel Martí
parent c6e47069af
commit 6d781decad
5 changed files with 29 additions and 6 deletions

View file

@ -375,7 +375,7 @@ func methods(t *types.Type) []*Sig {
// generating code if necessary.
var ms []*Sig
for _, f := range mt.AllMethods().Slice() {
if f.Type.Etype != TFUNC || f.Type.Recv() == nil {
if !f.IsMethod() {
Fatalf("non-method on %v method %v %v\n", mt, f.Sym, f)
}
if f.Type.Recv() == nil {