mirror of
https://github.com/golang/go
synced 2024-11-22 20:40:03 -07:00
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>
This commit is contained in:
parent
b003a8b1ae
commit
5c59e11f5e
@ -109,10 +109,6 @@ func sconv(s *Sym, verb rune, mode fmtMode) string {
|
|||||||
return "<S>"
|
return "<S>"
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Name == "_" {
|
|
||||||
return "_"
|
|
||||||
}
|
|
||||||
|
|
||||||
q := pkgqual(s.Pkg, verb, mode)
|
q := pkgqual(s.Pkg, verb, mode)
|
||||||
if q == "" {
|
if q == "" {
|
||||||
return s.Name
|
return s.Name
|
||||||
@ -136,10 +132,6 @@ func sconv2(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) {
|
|||||||
b.WriteString("<S>")
|
b.WriteString("<S>")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.Name == "_" {
|
|
||||||
b.WriteString("_")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
symfmt(b, s, verb, mode)
|
symfmt(b, s, verb, mode)
|
||||||
}
|
}
|
||||||
|
9
test/fixedbugs/issue47087.dir/a.go
Normal file
9
test/fixedbugs/issue47087.dir/a.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
func F() interface{} { return struct{ _ []int }{} }
|
||||||
|
|
||||||
|
var X = F()
|
9
test/fixedbugs/issue47087.dir/b.go
Normal file
9
test/fixedbugs/issue47087.dir/b.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package b
|
||||||
|
|
||||||
|
func F() interface{} { return struct{ _ []int }{} }
|
||||||
|
|
||||||
|
var X = F()
|
19
test/fixedbugs/issue47087.dir/main.go
Normal file
19
test/fixedbugs/issue47087.dir/main.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"a"
|
||||||
|
"b"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if a.F() == b.F() {
|
||||||
|
panic("FAIL")
|
||||||
|
}
|
||||||
|
if a.X == b.X {
|
||||||
|
panic("FAIL")
|
||||||
|
}
|
||||||
|
}
|
7
test/fixedbugs/issue47087.go
Normal file
7
test/fixedbugs/issue47087.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// rundir
|
||||||
|
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package ignored
|
Loading…
Reference in New Issue
Block a user