]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix lexical block of captured variables
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>
Fri, 18 Aug 2017 08:22:19 +0000 (10:22 +0200)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Sep 2017 21:02:59 +0000 (21:02 +0000)
commite1cf2be7a82a2421c69c48cbdf596841f29bff77
tree5734ccf494b9b3aa344e8950f7d9f0398870e0b1
parenta72e26f246a50b2d5226262420874b143d9d8b5a
cmd/compile: fix lexical block of captured variables

Variables captured by a closure were always assigned to the root scope
in their declaration function. Using decl.Name.Defn.Pos will result in
the correct scope for both the declaration function and the capturing
function.

Fixes #21515

Change-Id: I3960aface3c4fc97e15b36191a74a7bed5b5ebc1
Reviewed-on: https://go-review.googlesource.com/56830
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/scope_test.go