]>
Commit | Line | Data |
---|---|---|
b4c522fa IB |
1 | // PERMUTE_ARGS: |
2 | // REQUIRED_ARGS: -o- | |
3 | ||
4 | struct A(Args...) | |
5 | { | |
6 | enum i = 1; | |
7 | ||
8 | // base use case. | |
9 | Args[0].T mBase; | |
10 | static assert(is(typeof(mBase) == B.T)); | |
11 | // chained types | |
12 | Args[0].T.TT mChain; | |
13 | static assert(is(typeof(mChain) == B.T.TT)); | |
14 | // chained packs | |
15 | Args[1+1].FArgs[0] mChainPack; | |
16 | static assert(is(typeof(mChainPack) == B)); | |
17 | // expr | |
18 | enum mExpr = Args[1].i; | |
19 | static assert(mExpr == B.i); | |
20 | // Nested + index eval | |
21 | Args[Args[0].i2].T mNested; | |
22 | static assert(is(typeof(mNested) == B.T)); | |
23 | // index with constexpr | |
24 | Args[i].T mCEIndex; | |
25 | static assert(is(typeof(mCEIndex) == B.T)); | |
26 | // Nested + index with constexpr | |
27 | Args[Args[i].i2].T mNestedCE; | |
28 | static assert(is(typeof(mNestedCE) == B.T)); | |
29 | ||
30 | // alias, base use case | |
31 | alias UBase = Args[0].T; | |
32 | static assert(is(UBase == B.T)); | |
33 | // alias, chained types | |
34 | alias UChain = Args[0].T.TT; | |
35 | static assert(is(UChain == B.T.TT)); | |
36 | // alias, chained packs | |
37 | alias UChainPack = Args[1+1].FArgs[0]; | |
38 | static assert(is(UChainPack == B)); | |
39 | // alias, expr | |
40 | alias uExpr = Args[1].i; | |
41 | static assert(uExpr == B.i); | |
42 | // alias, Nested + index eval | |
43 | alias UNested = Args[Args[0].i2].T; | |
44 | static assert(is(UNested == B.T)); | |
45 | // alias, index with constexpr | |
46 | alias UCEIndex = Args[i].T; | |
47 | static assert(is(UCEIndex == B.T)); | |
48 | // alias, Nested + index with constexpr | |
49 | alias UNextedCE = Args[Args[i].i2].T; | |
50 | static assert(is(UNextedCE == B.T)); | |
51 | } | |
52 | ||
53 | struct B | |
54 | { | |
55 | struct T | |
56 | { | |
57 | struct TT | |
58 | { | |
59 | } | |
60 | } | |
61 | enum i = 6; | |
62 | enum i2 = 0; | |
63 | } | |
64 | ||
65 | struct C(Args...) | |
66 | { | |
67 | alias FArgs = Args; | |
68 | } | |
69 | ||
70 | alias Z = A!(B,B,C!(B,B)); | |
71 | ||
72 | /***************************************************/ | |
5fee5ec3 | 73 | // https://issues.dlang.org/show_bug.cgi?id=14889 |
b4c522fa IB |
74 | |
75 | struct A14889(alias Exc) | |
76 | { | |
77 | alias ExceptionType = Exc; | |
78 | } | |
79 | alias TT14889(Args...) = Args; | |
80 | ||
81 | alias X14889a = TT14889!(A14889!Throwable()); | |
82 | alias Y14889a = X14889a[0].ExceptionType; | |
83 | ||
84 | alias X14889b = TT14889!(A14889!Throwable); | |
85 | alias Y14889b = X14889b[0].ExceptionType; | |
86 | ||
87 | /***************************************************/ | |
5fee5ec3 | 88 | // https://issues.dlang.org/show_bug.cgi?id=14889 |
b4c522fa IB |
89 | |
90 | alias TypeTuple14900(T...) = T; | |
91 | ||
92 | struct S14900 | |
93 | { | |
94 | alias T = int; | |
95 | alias U = TypeTuple14900!(long,string); | |
96 | } | |
97 | ||
98 | alias Types14900 = TypeTuple14900!(S14900, S14900); | |
99 | ||
100 | Types14900[0].T a14900; // Types[0] == S, then typeof(a) == S.T == int | |
101 | Types14900[0].U[1] b14900; // Types[0].U == S.U, then typeof(b) == S.U[1] == string | |
102 | ||
103 | void test14900() | |
104 | { | |
105 | Types14900[0].T a; // Types[0] == S, then typeof(a) == S.T == int | |
106 | Types14900[0].U[1] b; // Types[0].U == S.U, then typeof(b) == S.U[1] == string | |
107 | } | |
108 | ||
109 | /***************************************************/ | |
5fee5ec3 | 110 | // https://issues.dlang.org/show_bug.cgi?id=14911 |
b4c522fa IB |
111 | |
112 | void test14911() | |
113 | { | |
114 | struct S {} | |
115 | ||
116 | int* buf1 = new int[2].ptr; // OK | |
117 | S* buf2 = (new S[2]).ptr; // OK | |
118 | S* buf3 = new S[2].ptr; // OK <- broken | |
119 | } | |
120 | ||
121 | /***************************************************/ | |
5fee5ec3 | 122 | // https://issues.dlang.org/show_bug.cgi?id=14986 |
b4c522fa IB |
123 | |
124 | alias Id14986(alias a) = a; | |
125 | ||
126 | struct Foo14986 | |
127 | { | |
128 | int tsize; | |
129 | } | |
130 | struct Bar14986 | |
131 | { | |
132 | enum Foo14986[] arr = [Foo14986()]; | |
133 | } | |
134 | ||
135 | Bar14986 test14986() | |
136 | { | |
137 | Foo14986[] types; | |
138 | auto a1 = new void[types[0].tsize]; // TypeIdentifier::toExpression | |
139 | auto a2 = new void[Id14986!types[0].tsize]; // TypeInstance::toExpression | |
140 | ||
141 | Bar14986 bar; | |
142 | auto a3 = Id14986!(typeof(bar).arr[0].tsize); // TypeTypeof::resolve | |
143 | auto a4 = Id14986!(typeof(return).arr[0].tsize); // TypeReturn::resolve | |
144 | ||
145 | return Bar14986(); | |
146 | } |