Source file test/fixedbugs/issue59378.go

     1  // compile
     2  
     3  // Copyright 2023 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.
     6  
     7  package p
     8  
     9  func f() {
    10  	F([]int{}, func(*int) bool { return true })
    11  }
    12  
    13  func F[S []E, E any](a S, fn func(*E) bool) {
    14  	for _, v := range a {
    15  		G(a, func(e E) bool { return fn(&v) })
    16  	}
    17  }
    18  
    19  func G[E any](s []E, f func(E) bool) int {
    20  	for i, v := range s {
    21  		if f(v) {
    22  			return i
    23  		}
    24  	}
    25  	return -1
    26  }
    27  

View as plain text