Files
go-legacy-win7/test/fixedbugs/issue69434.go

62 lines
772 B
Go
Raw Normal View History

2024-10-02 08:34:23 +10:00
// run
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"iter"
)
2025-02-14 12:42:07 +07:00
func All() iter.Seq[int] {
return func(yield func(int) bool) {
for i := 0; i < 10; i++ {
growStack(512)
if !yield(i) {
2024-10-02 08:34:23 +10:00
return
}
}
}
}
2025-02-14 12:42:07 +07:00
type S struct {
round int
2024-10-02 08:34:23 +10:00
}
2025-02-14 12:42:07 +07:00
func NewS(round int) *S {
s := &S{round: round}
return s
2024-10-02 08:34:23 +10:00
}
2025-02-14 12:42:07 +07:00
func (s *S) check(round int) {
if s.round != round {
panic("bad round")
2024-10-02 08:34:23 +10:00
}
}
2025-02-14 12:42:07 +07:00
func f() {
2024-10-02 08:34:23 +10:00
rounds := 0
2025-02-14 12:42:07 +07:00
s := NewS(rounds)
s.check(rounds)
2024-10-02 08:34:23 +10:00
2025-02-14 12:42:07 +07:00
for range All() {
s.check(rounds)
rounds++
s = NewS(rounds)
s.check(rounds)
2024-10-02 08:34:23 +10:00
}
2025-02-14 12:42:07 +07:00
}
2024-10-02 08:34:23 +10:00
2025-02-14 12:42:07 +07:00
func growStack(i int) {
if i == 0 {
return
2024-10-02 08:34:23 +10:00
}
2025-02-14 12:42:07 +07:00
growStack(i - 1)
2024-10-02 08:34:23 +10:00
}
func main() {
2025-02-14 12:42:07 +07:00
f()
2024-10-02 08:34:23 +10:00
}