1
0
mirror of https://github.com/golang/go synced 2024-10-01 03:38:32 -06:00

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
This commit is contained in:
Robert Griesemer 2013-07-24 10:49:44 -07:00
parent 407e159412
commit c5b1cc4227

View File

@ -480,6 +480,9 @@ func (check *checker) collectFields(list *ast.FieldList, cycleOk bool) (fields [
t, isPtr := deref(typ) t, isPtr := deref(typ)
switch t := t.(type) { switch t := t.(type) {
case *Basic: case *Basic:
if t == Typ[Invalid] {
continue // ignore this field - error was reported before
}
add(f, nil, t.name, true, pos) add(f, nil, t.name, true, pos)
case *Named: case *Named:
// spec: "An embedded type must be specified as a type name // 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) add(f, nil, t.obj.name, true, pos)
default: 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)
}
} }
} }
} }