]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: fix check to avoid creating new closure function when typechecking...
authorDan Scales <danscales@google.com>
Fri, 19 Feb 2021 02:07:09 +0000 (18:07 -0800)
committerDan Scales <danscales@google.com>
Fri, 19 Feb 2021 19:28:53 +0000 (19:28 +0000)
commit06b86e98031aacdd6f0499799cc4f50200ecfd18
tree6715f517b5de3f17d7d0ef5b853b9af301e2d3b9
parent9322eec8a267196d38cba657495624c3c91565f1
cmd/compile:  fix check to avoid creating new closure function when typechecking inline body

By default, when typechecking a closure, tcClosure() creates a new
closure function. This should really be done separate from typechecking.
For now, we explicitly avoid creating a new closure function when
typechecking an inline body (in ImportedBody). However, the heuristic
for determining when we are typechecking an inline body was not correct
for double nested closures in an inline body, since CurFunc will then be
the inner closure, which has a body.

So, use a simple global variable to indicate when we typechecking an
inline body. The global variable is fine (just like ir.CurFunc), since
the front-end runs serially.

Fixes #44325

Change-Id: If2829fe1ebb195a7b1a240192b57fe6f04d1a36b
Reviewed-on: https://go-review.googlesource.com/c/go/+/294211
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
src/cmd/compile/internal/typecheck/func.go
test/fixedbugs/issue44325.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue44325.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue44325.go [new file with mode: 0644]