Skip to content

Commit ce4cb55

Browse files
committed
internal/modindex: fix two bugs
Symbol types should be a single character, and now they are. func F(int, float) is legal. Before it was being treated as if it were F(), now it is treated as if it were F(_ int, _ float), which seems better. Change-Id: I051f60b16edccf54c4ce30f11b33a458413fa9af Reviewed-on: https://go-review.googlesource.com/c/tools/+/620138 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent b3482cc commit ce4cb55

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/modindex/symbols.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,14 @@ func getFileExports(f *ast.File) []symbol {
112112
continue
113113
}
114114
tp = strings.Replace(tp, " ", "$", -1)
115-
for _, y := range x.Names {
116-
result = append(result, y.Name)
115+
if len(x.Names) == 0 {
116+
result = append(result, "_")
117117
result = append(result, tp)
118+
} else {
119+
for _, y := range x.Names {
120+
result = append(result, y.Name)
121+
result = append(result, tp)
122+
}
118123
}
119124
}
120125
sigs := strings.Join(result, " ")
@@ -124,9 +129,9 @@ func getFileExports(f *ast.File) []symbol {
124129
case *ast.GenDecl:
125130
switch decl.Tok {
126131
case token.CONST, token.VAR:
127-
tp := " V"
132+
tp := "V"
128133
if decl.Tok == token.CONST {
129-
tp = " C"
134+
tp = "C"
130135
}
131136
for _, sp := range decl.Specs {
132137
for _, x := range sp.(*ast.ValueSpec).Names {
@@ -137,7 +142,7 @@ func getFileExports(f *ast.File) []symbol {
137142
}
138143
case token.TYPE:
139144
for _, sp := range decl.Specs {
140-
if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, " T", ""); s != nil {
145+
if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, "T", ""); s != nil {
141146
ans = append(ans, *s)
142147
}
143148
}

0 commit comments

Comments
 (0)