From 124e603d87b94159e6750e9f7c1d9beb5a80a9a6 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 24 Jun 2013 17:38:41 -0700 Subject: [PATCH] go.tools/go/types: imported structs may contain _ fields Don't report import errors due to (multiple) _ fields in imported structs. Fixes golang/go#5758. R=adonovan CC=golang-dev https://golang.org/cl/10529043 --- go/types/gcimporter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/types/gcimporter.go b/go/types/gcimporter.go index 3527587a..2ca0fd20 100644 --- a/go/types/gcimporter.go +++ b/go/types/gcimporter.go @@ -506,7 +506,10 @@ func (p *gcParser) parseStructType() Type { if tags != nil { tags = append(tags, tag) } - if alt := scope.Insert(fld); alt != nil { + if fld.name == "_" { + // blank identifiers are not declared + fld.setParent(scope) + } else if alt := scope.Insert(fld); alt != nil { pname := "" if pkg := alt.Pkg(); pkg != nil { pname = pkg.name