diff options
author | Dan Scales <danscales@google.com> | 2021-02-19 09:40:35 -0800 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-02-23 01:53:51 +0000 |
commit | 5f3dabbb79fb3dc8eea9a5050557e9241793dce3 (patch) | |
tree | 4a75c0169a1a4b0ad34684d09d9ac9e2069ba271 /src/cmd/compile/internal/typecheck/iimport.go | |
parent | 7af821a661be57cdd13212695cd6c1095487f2b4 (diff) | |
download | go-5f3dabbb79fb3dc8eea9a5050557e9241793dce3.tar.gz go-5f3dabbb79fb3dc8eea9a5050557e9241793dce3.zip |
cmd/compile: fix import of functions of multiple nested closure
For import of functions with closures, the connections among closure
variables are constructed on-the-fly via CaptureName(). For multiple
nested closures, we need to temporarily set r.curfn to each closure we
construct, so that the processing of closure variables will be correct
for any nested closure inside that closure.
Fixes #44335
Change-Id: I34f99e2822250542528ff6b2232bf36756140868
Reviewed-on: https://go-review.googlesource.com/c/go/+/294212
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iimport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iimport.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 7b5b113b15..29090a9178 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -986,15 +986,19 @@ func (r *importReader) node() ir.Node { fn.ClosureVars = cvars r.allClosureVars = append(r.allClosureVars, cvars...) - fn.Dcl = r.readFuncDcls(fn) - body := r.stmtList() + fn.Inl = &ir.Inline{} + // Read in the Dcls and Body of the closure after temporarily + // setting r.curfn to fn. + r.funcBody(fn) + fn.Dcl = fn.Inl.Dcl + fn.Body = fn.Inl.Body + fn.Inl = nil + ir.FinishCaptureNames(pos, r.curfn, fn) clo := ir.NewClosureExpr(pos, fn) fn.OClosure = clo - fn.Body = body - return clo // case OPTRLIT: |