Debian Codegraph @

gcc/testsuite/gdc.test/runnable/test16140.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=16140
2
3 int fun()
4 {
5 static int count = 0;
6 if (count == 3)
7 {
8 count = 0;
9 return 0;
10 }
11 ++count;
12 return count;
13 }
14
15 void main()
16 {
17 uint[] res;
18 while(auto value = fun())
19 res ~= value;
20 assert(res == [1, 2, 3]);
21
22 res.length = 0;
23 while(uint value = fun())
24 res ~= value;
25 assert(res == [1, 2, 3]);
26
27 res.length = 0;
28 while(const value = fun())
29 res ~= value;
30 assert(res == [1, 2, 3]);
31 }