In the old binary export format, parameter names for parameter lists
which contained only types where never written, so this problem didn't
come up.
Fixes #25101.
Change-Id: Ia8b817f7f467570b05f88d584e86b6ef4acdccc6
Reviewed-on: https://go-review.googlesource.com/116376
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
// origSym returns the original symbol written by the user.
func origSym(s *types.Sym) *types.Sym {
- if s != nil && s.Name[0] == '~' {
+ if s == nil {
+ return nil
+ }
+
+ if len(s.Name) > 1 && s.Name[0] == '~' {
switch s.Name[1] {
case 'r': // originally an unnamed result
- s = nil
+ return nil
case 'b': // originally the blank identifier _
// TODO(mdempsky): Does s.Pkg matter here?
- s = nblank.Sym
+ return nblank.Sym
}
+ return s
}
+
+ if strings.HasPrefix(s.Name, ".anon") {
+ // originally an unnamed or _ name (see subr.go: structargs)
+ return nil
+ }
+
return s
}
--- /dev/null
+// compile
+
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Indexed export format must not crash when writing
+// the anonymous parameter for m.
+
+package p
+
+var x interface {
+ m(int)
+}
+
+var M = x.m