• LE Manh Cuong's avatar
    cmd/compile: fix const declaration group broken with closure · 644543dd
    LE Manh Cuong authored
    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/+/172298Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
    Run-TryBot: Matthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    644543dd
issue30709.go 550 Bytes