1
// Copyright 2012 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
5
// This file contains tests for the rangeloop checker.
11
func RangeLoopTests() {
15
println(i) // ERROR "range variable i enclosed by function"
16
println(v) // ERROR "range variable v enclosed by function"
21
println(i) // ERROR "range variable i enclosed by function"
22
println(v) // ERROR "range variable v enclosed by function"
27
println(i) // ERROR "range variable i enclosed by function"
32
println(v) // ERROR "range variable v enclosed by function"
39
println("unfortunately, we don't catch the error above because of this statement")
52
// If the key of the range statement is not an identifier
53
// the code should not panic (it used to).
56
for x[0], f = range s {
58
_ = f // ERROR "range variable f enclosed by function"