1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:14:45 -07: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)
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,12 +500,10 @@ 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)
}
}
}
}
return
}