File: nested_gh3556.d

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (51 lines) | stat: -rw-r--r-- 986 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// https://github.com/ldc-developers/ldc/issues/3556
// RUN: %ldc -run %s

class C {
    int counter = 1;

    void test1() {
        assert(counter == 1);
        ++counter;
    }

    void run1() {
        class C2 {
            int counter2 = 11;

            class C3 {
                void run3() {
                    test1();
                    test2();
                    ++counter;
                    ++counter2;
                }
            }

            void test2() {
                assert(counter == 2);
                ++counter;
                assert(counter2 == 11);
                ++counter2;
            }

            void run2() {
                auto c3 = new C3;
                c3.run3();
                ++counter;
                ++counter2;
            }
        }

        auto c2 = new C2;
        c2.run2();
        assert(c2.counter2 == 14);
        ++counter;
    }
}

void main() {
    auto c = new C;
    c.run1();
    assert(c.counter == 6);
}