Skip to content

Commit 5c59e11

Browse files
committed
cmd/compile: remove special-casing of blank in types.sconv{,2}
I'm not sure why blank was special-cased here before, but it's wrong. Blank is a non-exported identifier, and writing it out without package-qualification can result in linker symbol collisions. Fixes #47087. Change-Id: Ie600037c8e54e3d4fdaeec21e2ca212badbd830b Reviewed-on: https://go-review.googlesource.com/c/go/+/333163 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
1 parent b003a8b commit 5c59e11

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

src/cmd/compile/internal/types/fmt.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ func sconv(s *Sym, verb rune, mode fmtMode) string {
109109
return "<S>"
110110
}
111111

112-
if s.Name == "_" {
113-
return "_"
114-
}
115-
116112
q := pkgqual(s.Pkg, verb, mode)
117113
if q == "" {
118114
return s.Name
@@ -136,10 +132,6 @@ func sconv2(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) {
136132
b.WriteString("<S>")
137133
return
138134
}
139-
if s.Name == "_" {
140-
b.WriteString("_")
141-
return
142-
}
143135

144136
symfmt(b, s, verb, mode)
145137
}

test/fixedbugs/issue47087.dir/a.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package a
6+
7+
func F() interface{} { return struct{ _ []int }{} }
8+
9+
var X = F()

test/fixedbugs/issue47087.dir/b.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package b
6+
7+
func F() interface{} { return struct{ _ []int }{} }
8+
9+
var X = F()

test/fixedbugs/issue47087.dir/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"a"
9+
"b"
10+
)
11+
12+
func main() {
13+
if a.F() == b.F() {
14+
panic("FAIL")
15+
}
16+
if a.X == b.X {
17+
panic("FAIL")
18+
}
19+
}

test/fixedbugs/issue47087.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rundir
2+
3+
// Copyright 2021 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package ignored

0 commit comments

Comments
 (0)