exp/types: fix crash in parseBasicType on unknown type

R=gri
CC=golang-dev
https://golang.org/cl/5302044
This commit is contained in:
Russ Cox 2011-10-19 12:49:01 -04:00
parent ec0b5533c9
commit bb8c4ed22a

View file

@ -289,9 +289,10 @@ func (p *gcParser) parseExportedName() (*ast.Object, string) {
// BasicType = identifier .
//
func (p *gcParser) parseBasicType() Type {
obj := Universe.Lookup(p.expect(scanner.Ident))
id := p.expect(scanner.Ident)
obj := Universe.Lookup(id)
if obj == nil || obj.Kind != ast.Typ {
p.errorf("not a basic type: %s", obj.Name)
p.errorf("not a basic type: %s", id)
}
return obj.Type.(Type)
}