Source file
test/fixedbugs/issue69434.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "iter"
11 )
12
13 func All() iter.Seq[int] {
14 return func(yield func(int) bool) {
15 for i := 0; i < 10; i++ {
16 growStack(512)
17 if !yield(i) {
18 return
19 }
20 }
21 }
22 }
23
24 type S struct {
25 round int
26 }
27
28 func NewS(round int) *S {
29 s := &S{round: round}
30 return s
31 }
32
33 func (s *S) check(round int) {
34 if s.round != round {
35 panic("bad round")
36 }
37 }
38
39 func f() {
40 rounds := 0
41 s := NewS(rounds)
42 s.check(rounds)
43
44 for range All() {
45 s.check(rounds)
46 rounds++
47 s = NewS(rounds)
48 s.check(rounds)
49 }
50 }
51
52 func growStack(i int) {
53 if i == 0 {
54 return
55 }
56 growStack(i - 1)
57 }
58
59 func main() {
60 f()
61 }
62
View as plain text