mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: do not declare func nodes
The primary responsibility of declare() to associate a symbol (Sym) with a declaration (Node), so "oldname" will work. Function literals are anonymous, so their symbols does not need to be declared. Passes toolstash-check. Change-Id: I739b1054e3953e85fbd74a99148b9cfd7e5a57eb Reviewed-on: https://go-review.googlesource.com/c/go/+/249078 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
ace37d35f1
commit
a4171d85d7
6 changed files with 13 additions and 26 deletions
|
|
@ -107,18 +107,7 @@ func typecheckclosure(clo *Node, top int) {
|
|||
}
|
||||
|
||||
xfunc.Func.Nname.Sym = closurename(Curfn)
|
||||
disableExport(xfunc.Func.Nname.Sym)
|
||||
if xfunc.Func.Nname.Sym.Def != nil {
|
||||
// The only case we can reach here is when the outer function was redeclared.
|
||||
// In that case, don't bother to redeclare the closure. Otherwise, we will get
|
||||
// a spurious error message, see #17758. While we are here, double check that
|
||||
// we already reported other error.
|
||||
if nsavederrors+nerrors == 0 {
|
||||
Fatalf("unexpected symbol collision %v", xfunc.Func.Nname.Sym)
|
||||
}
|
||||
} else {
|
||||
declare(xfunc.Func.Nname, PFUNC)
|
||||
}
|
||||
setNodeNameFunc(xfunc.Func.Nname)
|
||||
xfunc = typecheck(xfunc, ctxStmt)
|
||||
|
||||
// Type check the body now, but only if we're inside a function.
|
||||
|
|
@ -473,7 +462,6 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node {
|
|||
tfn.List.Set(structargs(t0.Params(), true))
|
||||
tfn.Rlist.Set(structargs(t0.Results(), false))
|
||||
|
||||
disableExport(sym)
|
||||
xfunc := dclfunc(sym, tfn)
|
||||
xfunc.Func.SetDupok(true)
|
||||
xfunc.Func.SetNeedctxt(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue