aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ir
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-08-20 10:19:28 -0700
committerKeith Randall <khr@golang.org>2021-08-23 17:51:41 +0000
commit8486ced8b09f4425bfd85e09b021dc78f93aea08 (patch)
tree1c778d44a91c3d0ab320d4d9aa8093cf7a29dc81 /src/cmd/compile/internal/ir
parentaeec6dbfe009f371021bddba13e2eb18e5d1a469 (diff)
downloadgo-8486ced8b09f4425bfd85e09b021dc78f93aea08.tar.gz
go-8486ced8b09f4425bfd85e09b021dc78f93aea08.zip
cmd/compile: copy captured dictionary var to local var
When starting a closure that needs a dictionary, copy the closure variable to a local variable. This lets child closures capture that dictionary variable correctly. This is a better fix for #47684, which does not cause problems like #47723. Fixes #47723 Update #47684 Change-Id: Ib5d9ffc68a5142e28daa7d0d75683e7a35508540 Reviewed-on: https://go-review.googlesource.com/c/go/+/343871 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ir')
-rw-r--r--src/cmd/compile/internal/ir/name.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ir/name.go b/src/cmd/compile/internal/ir/name.go
index 48fe572124..a2eec05013 100644
--- a/src/cmd/compile/internal/ir/name.go
+++ b/src/cmd/compile/internal/ir/name.go
@@ -404,9 +404,7 @@ func CaptureName(pos src.XPos, fn *Func, n *Name) *Name {
if n.Op() != ONAME || n.Curfn == nil {
return n // okay to use directly
}
- if n.IsClosureVar() && n.Sym().Name != ".dict" {
- // Note: capturing dictionary closure variables is ok. This makes
- // sure the generated code is correctly optimized.
+ if n.IsClosureVar() {
base.FatalfAt(pos, "misuse of CaptureName on closure variable: %v", n)
}