]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: fix panic with dead hidden closures
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sun, 15 Aug 2021 19:15:28 +0000 (02:15 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 16 Aug 2021 18:20:12 +0000 (18:20 +0000)
commite61d1445ab2304e2d6e4711f8477061192d5942c
treeb1611c1766230336a4b6180c676123f01a940fd0
parent5c7a460a1c108e5bf7a99817b86ebded7ce81812
cmd/compile: fix panic with dead hidden closures

Currently, for hidden closures, we always push them to compile queue
during typechecking. If the hidden closure is discarded from the outer
function body during deadcode, any desugaring phase after deadcode won't
be applied to the closure. Thus, some un-expected OPs are passed to
downstream passes, which they can't handle, the compiler goes boom!

To fix this, we keep track of discarded hidden closures during deadcode
pass, and won't compile them then.

Fixes #47712

Change-Id: I078717d5d1f4f2fa39cbaf610cfffbb042e70ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/342350
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/deadcode/deadcode.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/ir/func.go
test/fixedbugs/issue47712.go [new file with mode: 0644]