github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa4004/testdata/src/example.com/CheckIneffectiveLoop/CheckIneffectiveLoop_generics.go (about) 1 //go:build go1.18 2 3 package pkg 4 5 func _[T map[int]int]() { 6 for range (T)(nil) { 7 if true { 8 println() 9 } 10 break 11 } 12 } 13 14 func _[K comparable, V any, M ~map[K]V]() { 15 for range (M)(nil) { 16 if true { 17 println() 18 } 19 break 20 } 21 } 22 23 func _[T []int]() { 24 for range (T)(nil) { 25 if true { 26 println() 27 } 28 break //@ diag(`the surrounding loop is unconditionally terminated`) 29 } 30 } 31 32 func _[T any, S ~[]T](x S) { 33 for range x { 34 if true { 35 println() 36 } 37 break //@ diag(`the surrounding loop is unconditionally terminated`) 38 } 39 }