mirror of
https://github.com/golang/go
synced 2024-11-05 18:36:08 +00:00
cmd/compile: revert internal parameter rename (from ".anonX" to "") before export
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>
This commit is contained in:
parent
e7ee3b91c4
commit
9be4f312bf
2 changed files with 30 additions and 3 deletions
|
@ -778,15 +778,26 @@ func functypefield0(t *types.Type, this *types.Field, in, out []*types.Field) {
|
|||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
16
test/fixedbugs/issue25101.go
Normal file
16
test/fixedbugs/issue25101.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
// 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
|
Loading…
Reference in a new issue