From c5b1cc4227e168b52af8d388ba4e7f9f5688ce6a Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 24 Jul 2013 10:49:44 -0700 Subject: [PATCH] go.tool/go/types: ignore invalid anonymous fields Fixes go tool vet breakage when applied to files with incomplete type information for anonymous fields. R=adonovan CC=golang-dev https://golang.org/cl/11773043 --- go/types/typexpr.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/go/types/typexpr.go b/go/types/typexpr.go index 91a93b13..8ddaf4ec 100644 --- a/go/types/typexpr.go +++ b/go/types/typexpr.go @@ -480,6 +480,9 @@ func (check *checker) collectFields(list *ast.FieldList, cycleOk bool) (fields [ t, isPtr := deref(typ) switch t := t.(type) { case *Basic: + if t == Typ[Invalid] { + continue // ignore this field - error was reported before + } add(f, nil, t.name, true, pos) case *Named: // spec: "An embedded type must be specified as a type name @@ -497,9 +500,7 @@ func (check *checker) collectFields(list *ast.FieldList, cycleOk bool) (fields [ } add(f, nil, t.obj.name, true, pos) default: - if typ != Typ[Invalid] { - check.invalidAST(pos, "anonymous field type %s must be named", typ) - } + check.invalidAST(pos, "anonymous field type %s must be named", typ) } } }