diff --git a/go/gcimporter/gcimporter.go b/go/gcimporter/gcimporter.go index 18e6f7b459f..0812de7ed93 100644 --- a/go/gcimporter/gcimporter.go +++ b/go/gcimporter/gcimporter.go @@ -473,7 +473,12 @@ func (p *parser) parseField() (*types.Var, string) { } tag := "" if p.tok == scanner.String { - tag = p.expect(scanner.String) + s := p.expect(scanner.String) + var err error + tag, err = strconv.Unquote(s) + if err != nil { + p.errorf("invalid struct tag %s: %s", s, err) + } } return types.NewField(token.NoPos, pkg, name, typ, anonymous), tag } @@ -509,8 +514,9 @@ func (p *parser) parseStructType() types.Type { // func (p *parser) parseParameter() (par *types.Var, isVariadic bool) { _, name := p.parseName(false) - if name == "" { - name = "_" // cannot access unnamed identifiers + // remove gc-specific parameter numbering + if i := strings.Index(name, "·"); i >= 0 { + name = name[:i] } if p.tok == '.' { p.expectSpecial("...") diff --git a/go/gcimporter/gcimporter_test.go b/go/gcimporter/gcimporter_test.go index 4e64e79ac28..094c5f5853c 100644 --- a/go/gcimporter/gcimporter_test.go +++ b/go/gcimporter/gcimporter_test.go @@ -128,7 +128,7 @@ var importedObjectTests = []struct { {"math.Pi", "const Pi untyped float"}, {"io.Reader", "type Reader interface{Read(p []byte) (n int, err error)}"}, {"io.ReadWriter", "type ReadWriter interface{Read(p []byte) (n int, err error); Write(p []byte) (n int, err error)}"}, - {"math.Sin", "func Sin(x·2 float64) (_ float64)"}, + {"math.Sin", "func Sin(x float64) float64"}, // TODO(gri) add more tests }