1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail337.d(13): Error: static assert  `0` is false
5 fail_compilation/fail337.d(26):        instantiated from here: bar!()
6 fail_compilation/fail337.d(33):        100 recursive instantiations from here: foo!196
7 fail_compilation/fail337.d(41):        253 recursive instantiations from here: baz!300
8 ---
9 */
10 
bar()11 template bar()
12 {
13     static assert(0);
14 }
15 
foo(int N)16 template foo(int N)
17 {
18     static if (N > 0)
19     {
20         static if (N & 1)
21             alias foo!(N - 3) foo;
22         else
23             alias foo!(N - 1) foo;
24     }
25     else
26         alias bar!() foo;
27 }
28 
baz(int M)29 template baz(int M)
30 {
31     static if (M < 50)
32     {
33         alias foo!(M * 4) baz;
34     }
35     else
36         alias baz!(M - 1) baz;
37 }
38 
main()39 void main()
40 {
41     int x = baz!(300);
42 }
43