aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2020-08-15 00:44:58 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2020-08-19 02:25:13 +0000
commitac875bc923db2b7350f244f06a06557e6fd97e05 (patch)
tree39134eac5fd74b833b2e919b09d2cb2bad44e1cb /src/cmd
parent98a0071a5363e307c2e284034f810378de3883dd (diff)
downloadgo-ac875bc923db2b7350f244f06a06557e6fd97e05.tar.xz
cmd/compile: don't bother to declare closure inside redeclared func
Fixes #17758 Change-Id: I75f5dc5be85fd8a6791ac89dfc0681be759cca36 Reviewed-on: https://go-review.googlesource.com/c/go/+/248517 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/compile/internal/gc/closure.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/gc/closure.go b/src/cmd/compile/internal/gc/closure.go
index 04fb7d5495..23e48939b4 100644
--- a/src/cmd/compile/internal/gc/closure.go
+++ b/src/cmd/compile/internal/gc/closure.go
@@ -108,7 +108,17 @@ func typecheckclosure(clo *Node, top int) {
xfunc.Func.Nname.Sym = closurename(Curfn)
disableExport(xfunc.Func.Nname.Sym)
- declare(xfunc.Func.Nname, PFUNC)
+ 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)
+ }
xfunc = typecheck(xfunc, ctxStmt)
// Type check the body now, but only if we're inside a function.