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
76 for i := range [2]int{} {
79 return i // test that we capture by ref here, i is mutated on every interaction
94 return q // test that we capture by ref here
95 // q++ must on a different decldepth than q declaration
110 }()] = range [2]int{} {
112 return q // test that we capture by ref here
113 // q++ must on a different decldepth than q declaration
124 q, g = 1, func() int { return q }
126 g = func() int { return 2 }