1// errorcheck -t 10
2
3// Copyright 2021 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
7package p
8
9// The init cycle diagnosis used to take exponential time
10// to traverse the call graph paths. This test case takes
11// at least two minutes on a modern laptop with the bug
12// and runs in a fraction of a second without it.
13// 10 seconds (-t 10 above) should be plenty if the code is working.
14
15var x = f() + z() // ERROR "initialization cycle"
16
17func f() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
18func z() int { return x }
19
20func a1() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
21func a2() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
22func a3() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
23func a4() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
24func a5() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
25func a6() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
26func a7() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
27func a8() int { return b1() + b2() + b3() + b4() + b5() + b6() + b7() }
28
29func b1() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
30func b2() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
31func b3() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
32func b4() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
33func b5() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
34func b6() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
35func b7() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
36func b8() int { return a1() + a2() + a3() + a4() + a5() + a6() + a7() }
37