Debian Codegraph @

go/ssa/interp/testdata/fixedbugs/issue69298.go

raw symbols SCIP
1 // Copyright 2024 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.
4
5 package main
6
7 import (
8 "fmt"
9 )
10
11 type Seq[V any] func(yield func(V) bool)
12
13 func AppendSeq[Slice ~[]E, E any](s Slice, seq Seq[E]) Slice {
14 for v := range seq {
15 s = append(s, v)
16 }
17 return s
18 }
19
20 func main() {
21 seq := func(yield func(int) bool) {
22 for i := 0; i < 10; i += 2 {
23 if !yield(i) {
24 return
25 }
26 }
27 }
28
29 s := AppendSeq([]int{1, 2}, seq)
30 fmt.Println(s)
31 }