]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix const declaration group broken with closure
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Tue, 16 Apr 2019 13:32:31 +0000 (20:32 +0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 16 Apr 2019 19:07:42 +0000 (19:07 +0000)
commit644543dd6447b39800825f66411df06066baa84e
tree37f76534710aa6ba39bd690d9ecf65356d3c9c5c
parent2bdbc942f5ae3da8cad8d0f2bd3f4ce75a821e6c
cmd/compile: fix const declaration group broken with closure

In typecheckclosure, a xfunc node will be put to xtop. But that node can
be shared between multiple closures, like in a const declaration group:

const (
x = unsafe.Sizeof(func() {})
y
)

It makes a xfunc node appears multiple times in xtop, causing duplicate
initLSym run.

To fix this issue, we only do typecheck for xfunc one time, and setup
closure node earlier in typecheckclosure process.

Fixes #30709

Change-Id: Ic924a157ee9f3e5d776214bef5390849ddc8aab9
Reviewed-on: https://go-review.googlesource.com/c/go/+/172298
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/closure.go
test/fixedbugs/issue30709.go [new file with mode: 0644]
test/fixedbugs/issue30709.out [new file with mode: 0644]