1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail10254.d(18): Error: pure function 'fail10254.foo' cannot call impure constructor 'fail10254.C.this'
5 fail_compilation/fail10254.d(18): Error: @safe function 'fail10254.foo' cannot call @system constructor 'fail10254.C.this'
6 fail_compilation/fail10254.d(19): Error: pure function 'fail10254.foo' cannot call impure constructor 'fail10254.S.this'
7 fail_compilation/fail10254.d(19): Error: @safe function 'fail10254.foo' cannot call @system constructor 'fail10254.S.this'
8 ---
9 */
10 
11 int a;
12 
this()13 class C { this() { a = 2; } }
thisS14 struct S { this(int) { a = 2; } }
15 
foo()16 void foo() pure @safe
17 {
18     auto c = new C; // This line should be a compilation error.
19     auto s = new S(1);
20 }
21