| 1 |
/******************************************** |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/traits_initSymbol.d(105): Error: struct / class type expected as argument to __traits(initSymbol) instead of `int` |
| 5 |
fail_compilation/traits_initSymbol.d(106): Error: struct / class type expected as argument to __traits(initSymbol) instead of `S[2]` |
| 6 |
fail_compilation/traits_initSymbol.d(107): Error: struct / class type expected as argument to __traits(initSymbol) instead of `123` |
| 7 |
--- |
| 8 |
*/ |
| 9 |
#line 100 |
| 10 |
|
| 11 |
struct S { int i = 4; } |
| 12 |
|
| 13 |
void test1() |
| 14 |
{ |
| 15 |
const void[] initInt = __traits(initSymbol, int); |
| 16 |
const void[] initArray = __traits(initSymbol, S[2]); |
| 17 |
const void[] initValue = __traits(initSymbol, 123); |
| 18 |
} |
| 19 |
|
| 20 |
/******************************************** |
| 21 |
TEST_OUTPUT: |
| 22 |
--- |
| 23 |
fail_compilation/traits_initSymbol.d(203): Error: cannot determine the address of the initializer symbol during CTFE |
| 24 |
fail_compilation/traits_initSymbol.d(203): called from here: `(*function () pure nothrow @nogc @safe => S)()` |
| 25 |
--- |
| 26 |
*/ |
| 27 |
#line 200 |
| 28 |
|
| 29 |
void test2() |
| 30 |
{ |
| 31 |
enum initLen = (() => __traits(initSymbol, S))(); |
| 32 |
} |
| 33 |
|
| 34 |
/******************************************** |
| 35 |
TEST_OUTPUT: |
| 36 |
--- |
| 37 |
fail_compilation/traits_initSymbol.d(305): Error: struct / class type expected as argument to __traits(initSymbol) instead of `traits_initSymbol.Interface` |
| 38 |
--- |
| 39 |
*/ |
| 40 |
#line 300 |
| 41 |
|
| 42 |
interface Interface {} |
| 43 |
|
| 44 |
void test3() |
| 45 |
{ |
| 46 |
const void[] initInterface = __traits(initSymbol, Interface); |
| 47 |
} |
| 48 |
|
| 49 |
/******************************************** |
| 50 |
TEST_OUTPUT: |
| 51 |
--- |
| 52 |
fail_compilation/traits_initSymbol.d(404): Error: expected 1 arguments for `initSymbol` but had 0 |
| 53 |
fail_compilation/traits_initSymbol.d(405): Error: expected 1 arguments for `initSymbol` but had 2 |
| 54 |
--- |
| 55 |
*/ |
| 56 |
#line 400 |
| 57 |
|
| 58 |
|
| 59 |
void test4() |
| 60 |
{ |
| 61 |
const void[] tmp = __traits(initSymbol); |
| 62 |
const void[] tmo = __traits(initSymbol, Interface, S); |
| 63 |
} |