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