Debian Codegraph @

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

raw
1 // https://issues.dlang.org/show_bug.cgi?id=22854
2 void main()
3 {
4 uint loops = 0;
5 static foreach (i; 0 .. 5)
6 {
7 static foreach (ch; SomeContainer().range)
8 loops++;
9 }
10 assert(loops == 5 * 5);
11 }
12
13 struct SomeContainer
14 {
15 SomeRange range() { return SomeRange(); }
16 TypeWithDestructor data;
17 }
18
19 struct TypeWithDestructor { ~this() { } }
20
21 struct SomeRange
22 {
23 int count = 5;
24 int front() { return count; }
25 bool empty() { return count <= 0; }
26 void popFront() { count--; }
27 }