]>
Commit | Line | Data |
---|---|---|
5a0aa603 IB |
1 | |
2 | alias fun = mixin("(){}"); | |
3 | ||
4 | void test1() | |
5 | { | |
6 | int x = 1; | |
7 | static immutable c = 2; | |
8 | ||
9 | fun(); | |
10 | foo!(mixin("int"))(); | |
11 | foo!(mixin("long*"))(); | |
12 | foo!(mixin("ST!(int, S.T)"))(); | |
13 | foo!(mixin(ST!(int, S.T)))(); | |
14 | ||
15 | int[mixin("string")] a1; | |
16 | int[mixin("5")] a2; | |
17 | int[mixin("c")] a3; | |
18 | int[] v1 = new int[mixin("3")]; | |
19 | auto v2 = new int[mixin("x")]; | |
20 | ||
21 | mixin(q{__traits(getMember, S, "T")}) ftv; | |
22 | ||
23 | alias T = int*; | |
24 | static assert(__traits(compiles, mixin("int"))); | |
25 | static assert(__traits(compiles, mixin(q{int[mixin("string")]}))); | |
26 | static assert(__traits(compiles, mixin(q{int[mixin("2")]}))); | |
27 | static assert(__traits(compiles, mixin(T))); | |
28 | static assert(__traits(compiles, mixin("int*"))); | |
29 | static assert(__traits(compiles, mixin(typeof(0)))); | |
30 | } | |
31 | ||
32 | struct S { alias T = float*; } | |
33 | ||
34 | struct ST(X,Y) {} | |
35 | ||
36 | void foo(alias t)() {} | |
37 | ||
38 | /**************************************************/ | |
39 | // https://issues.dlang.org/show_bug.cgi?id=21074 | |
40 | ||
41 | alias Byte = ubyte; | |
42 | alias Byte2(A) = ubyte; | |
43 | alias T0 = mixin(q{const(Byte)})*; | |
44 | alias T1 = mixin(q{const(Byte[1])})*; | |
45 | alias T2 = mixin(q{const(Byte2!int)})*; | |
46 | alias T3 = mixin(q{const(mixin(Byte2!int))})*; | |
47 | alias T4 = mixin(q{const(mixin("__traits(getMember, S, \"T\")"))})*; | |
48 | alias T5 = const(mixin(q{Byte}))*; | |
49 | alias T6 = const(mixin(q{immutable(Byte)}))*; | |
50 | alias T7 = const(mixin(q{shared(Byte)}))*; | |
51 | alias T8 = const(mixin(q{Byte*})); | |
52 | ||
53 | // the following tests now work | |
54 | static assert(is(T0 == const(ubyte)*)); | |
55 | static assert(is(T1 == const(ubyte[1])*)); | |
56 | static assert(is(T2 == const(ubyte)*)); | |
57 | static assert(is(T3 == const(ubyte)*)); | |
58 | static assert(is(T4 == const(float*)*)); | |
59 | static assert(is(T5 == const(ubyte)*)); | |
60 | static assert(is(T6 == immutable(ubyte)*)); | |
61 | static assert(is(T7 == const(shared(ubyte))*)); | |
62 | static assert(is(T8 == const(ubyte*))); | |
63 | ||
64 | // this doesn't work but I'll file a new issue | |
65 | /* | |
66 | alias T8 = mixin(q{immutable(__traits(getMember, S, "T"))})*; | |
67 | static assert(is(T8 == immutable(float*)*)); | |
68 | */ |