mirror of
https://github.com/golang/go
synced 2024-11-05 18:36:08 +00:00
cmd/gc: fix import of package with var func returning _
Fixes #8280. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews, r https://golang.org/cl/146240043
This commit is contained in:
parent
fb4e185a99
commit
43c4287b25
4 changed files with 22 additions and 10 deletions
|
@ -1108,16 +1108,11 @@ exprfmt(Fmt *f, Node *n, int prec)
|
|||
|
||||
case ONAME:
|
||||
// Special case: name used as local variable in export.
|
||||
switch(n->class&~PHEAP){
|
||||
case PAUTO:
|
||||
case PPARAM:
|
||||
case PPARAMOUT:
|
||||
// _ becomes ~b%d internally; print as _ for export
|
||||
if(fmtmode == FExp && n->sym && n->sym->name[0] == '~' && n->sym->name[1] == 'b')
|
||||
return fmtprint(f, "_");
|
||||
if(fmtmode == FExp && n->sym && !isblank(n) && n->vargen > 0)
|
||||
return fmtprint(f, "%S·%d", n->sym, n->vargen);
|
||||
}
|
||||
// _ becomes ~b%d internally; print as _ for export
|
||||
if(fmtmode == FExp && n->sym && n->sym->name[0] == '~' && n->sym->name[1] == 'b')
|
||||
return fmtprint(f, "_");
|
||||
if(fmtmode == FExp && n->sym && !isblank(n) && n->vargen > 0)
|
||||
return fmtprint(f, "%S·%d", n->sym, n->vargen);
|
||||
|
||||
// Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
|
||||
// but for export, this should be rendered as (*pkg.T).meth.
|
||||
|
|
3
test/fixedbugs/issue8280.dir/a.go
Normal file
3
test/fixedbugs/issue8280.dir/a.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package a
|
||||
|
||||
var Bar = func() (_ int) { return 0 }
|
5
test/fixedbugs/issue8280.dir/b.go
Normal file
5
test/fixedbugs/issue8280.dir/b.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package b
|
||||
|
||||
import "./a"
|
||||
|
||||
var foo = a.Bar
|
9
test/fixedbugs/issue8280.go
Normal file
9
test/fixedbugs/issue8280.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
// compiledir
|
||||
|
||||
// Copyright 2014 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.
|
||||
|
||||
// Issue 8280: cannot import package exporting a func var returning a result named _
|
||||
|
||||
package ignored
|
Loading…
Reference in a new issue