3 // Copyright 2015 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Check that these do not use "by value" capturing,
8 // because changes are made to the value during the closure.
46 for z.a[1] = 1; i < 10; i++ {
63 tmp = w // force capture of w, but do not write to it yet
67 w++ // write in a nested closure
77 for i = range [2]int{} {
80 return i // test that we capture by ref here, i is mutated on every interaction
95 return q // test that we capture by ref here
96 // q++ must on a different decldepth than q declaration
111 }()] = range [2]int{} {
113 return q // test that we capture by ref here
114 // q++ must on a different decldepth than q declaration
125 q, g = 1, func() int { return q }
127 g = func() int { return 2 }