7 fail_compilation/fail_arrayop2.d(13): Error: array operation `[1, 2, 3] - [1, 2, 3]` without destination memory not allowed
8 fail_compilation/fail_arrayop2.d(16): Error: invalid array operation `"a" - "b"` (possible missing [])
11 void test2603() // https://issues.dlang.org/show_bug.cgi?id=2603 - ICE(cgcs.c) on subtracting string literals
13 auto c1
= [1,2,3] - [1,2,3];
15 // this variation is wrong code on D2, ICE ..\ztc\cgcs.c 358 on D1.
16 string c2
= "a" - "b";
22 fail_compilation/fail_arrayop2.d(38): Error: array operation `-a[]` without destination memory not allowed (possible missing [])
23 fail_compilation/fail_arrayop2.d(39): Error: array operation `~a[]` without destination memory not allowed (possible missing [])
24 fail_compilation/fail_arrayop2.d(41): Error: array operation `a[] + a[]` without destination memory not allowed (possible missing [])
25 fail_compilation/fail_arrayop2.d(42): Error: array operation `a[] - a[]` without destination memory not allowed (possible missing [])
26 fail_compilation/fail_arrayop2.d(43): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing [])
27 fail_compilation/fail_arrayop2.d(44): Error: array operation `a[] / a[]` without destination memory not allowed (possible missing [])
28 fail_compilation/fail_arrayop2.d(45): Error: array operation `a[] % a[]` without destination memory not allowed (possible missing [])
29 fail_compilation/fail_arrayop2.d(46): Error: array operation `a[] ^ a[]` without destination memory not allowed (possible missing [])
30 fail_compilation/fail_arrayop2.d(47): Error: array operation `a[] & a[]` without destination memory not allowed (possible missing [])
31 fail_compilation/fail_arrayop2.d(48): Error: array operation `a[] | a[]` without destination memory not allowed (possible missing [])
32 fail_compilation/fail_arrayop2.d(49): Error: array operation `a[] ^^ a[]` without destination memory not allowed (possible missing [])
55 fail_compilation/fail_arrayop2.d(75): Error: array operation `a[] + a[]` without destination memory not allowed
56 fail_compilation/fail_arrayop2.d(76): Error: array operation `a[] - a[]` without destination memory not allowed
57 fail_compilation/fail_arrayop2.d(77): Error: array operation `a[] * a[]` without destination memory not allowed
58 fail_compilation/fail_arrayop2.d(78): Error: array operation `a[] / a[]` without destination memory not allowed
59 fail_compilation/fail_arrayop2.d(79): Error: array operation `a[] % a[]` without destination memory not allowed
60 fail_compilation/fail_arrayop2.d(80): Error: array operation `a[] ^ a[]` without destination memory not allowed
61 fail_compilation/fail_arrayop2.d(81): Error: array operation `a[] & a[]` without destination memory not allowed
62 fail_compilation/fail_arrayop2.d(82): Error: array operation `a[] | a[]` without destination memory not allowed
63 fail_compilation/fail_arrayop2.d(83): Error: array operation `a[] ^^ 10` without destination memory not allowed
64 fail_compilation/fail_arrayop2.d(84): Error: array operation `-a[]` without destination memory not allowed
65 fail_compilation/fail_arrayop2.d(85): Error: array operation `~a[]` without destination memory not allowed
66 fail_compilation/fail_arrayop2.d(90): Error: array operation `[1] + a[]` without destination memory not allowed
67 fail_compilation/fail_arrayop2.d(91): Error: array operation `[1] + a[]` without destination memory not allowed
87 // from https://issues.dlang.org/show_bug.cgi?id=11992
90 arr1
~= [1] + a
[]; // NG
91 arr2
~= [1] + a
[]; // NG
97 fail_compilation/fail_arrayop2.d(105): Error: array operation `h * y[]` without destination memory not allowed
105 double[2] temp1
= cast(double[2])(h
* y
[]);
111 fail_compilation/fail_arrayop2.d(118): Error: array operation `-a[]` without destination memory not allowed
112 fail_compilation/fail_arrayop2.d(120): Error: array operation `(-a[])[0..4]` without destination memory not allowed
115 float[] test12769(float[] a
)
126 fail_compilation/fail_arrayop2.d(137): Error: array operation `a[] - a[]` without destination memory not allowed
127 fail_compilation/fail_arrayop2.d(139): Error: array operation `a[] - a[]` without destination memory not allowed
128 fail_compilation/fail_arrayop2.d(140): Error: array operation `a[] - a[]` without destination memory not allowed
129 fail_compilation/fail_arrayop2.d(143): Error: array operation `a[] - a[]` without destination memory not allowed
130 fail_compilation/fail_arrayop2.d(145): Error: array operation `a[] - a[]` without destination memory not allowed
137 auto arr
= [a
[] - a
[]][0];
139 auto aa1
= [1 : a
[] - a
[]];
140 auto aa2
= [a
[] - a
[] : 1];
142 struct S
{ int[] a
; }
143 auto s
= S(a
[] - a
[]);
145 auto n
= int(a
[] - a
[]);
151 fail_compilation/fail_arrayop2.d(160): Error: array operation `a[] * a[]` without destination memory not allowed
152 fail_compilation/fail_arrayop2.d(161): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed
153 fail_compilation/fail_arrayop2.d(164): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing [])
154 fail_compilation/fail_arrayop2.d(165): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed (possible missing [])
160 auto b1
= (a
[] * a
[])[];
161 auto b2
= (a
[] * a
[])[0..1];
165 c
= (a
[] * a
[])[0..1];
171 fail_compilation/fail_arrayop2.d(181): Error: array operation `data[segmentId][28..29] & cast(ubyte)(1 << 0)` without destination memory not allowed
181 return !!((data
[segmentId
][28..29]) & (1 << 0));
188 fail_compilation/fail_arrayop2.d(195): Error: array operation `a[] + 1` without destination memory not allowed
189 fail_compilation/fail_arrayop2.d(195): Error: array operation `a[] * 2` without destination memory not allowed
195 int[] b
= (a
[] + 1) ~ a
[] * 2;
201 fail_compilation/fail_arrayop2.d(247): Error: array operation `[1] * 6` without destination memory not allowed
202 fail_compilation/fail_arrayop2.d(248): Error: array operation `[1] * 6` without destination memory not allowed
203 fail_compilation/fail_arrayop2.d(249): Error: array operation `[1] * 6` without destination memory not allowed
204 fail_compilation/fail_arrayop2.d(253): Error: array operation `[1] * 6` without destination memory not allowed
205 fail_compilation/fail_arrayop2.d(256): Error: array operation `[1] * 6` without destination memory not allowed
206 fail_compilation/fail_arrayop2.d(265): Error: array operation `[1] * 6` without destination memory not allowed
207 fail_compilation/fail_arrayop2.d(268): Error: array operation `[1] * 6` without destination memory not allowed
208 fail_compilation/fail_arrayop2.d(269): Error: array operation `"abc"[] + '\x01'` without destination memory not allowed
209 fail_compilation/fail_arrayop2.d(272): Error: array operation `[1] * 6` without destination memory not allowed
210 fail_compilation/fail_arrayop2.d(275): Error: cannot take address of expression `([1] * 6)[0..2]` because it is not an lvalue
211 fail_compilation/fail_arrayop2.d(278): Error: can only `*` a pointer, not a `int[]`
212 fail_compilation/fail_arrayop2.d(281): Error: the `delete` keyword is obsolete
213 fail_compilation/fail_arrayop2.d(281): use `object.destroy()` (and `core.memory.GC.free()` if applicable) instead
214 fail_compilation/fail_arrayop2.d(284): Error: array operation `da[] * 6` without destination memory not allowed
215 fail_compilation/fail_arrayop2.d(287): Error: array operation `da[] * 6` without destination memory not allowed
216 fail_compilation/fail_arrayop2.d(290): Error: cannot modify expression `[1] * 6` because it is not an lvalue
217 fail_compilation/fail_arrayop2.d(291): Error: array operation `[1] * 6` without destination memory not allowed
218 fail_compilation/fail_arrayop2.d(294): Error: cannot modify expression `[1] * 6` because it is not an lvalue
219 fail_compilation/fail_arrayop2.d(295): Error: cannot modify expression `([1] * 6)[]` because it is not an lvalue
220 fail_compilation/fail_arrayop2.d(298): Error: array operation `[1] * 6` without destination memory not allowed
221 fail_compilation/fail_arrayop2.d(299): Error: array operation `[1] * 6` without destination memory not allowed
222 fail_compilation/fail_arrayop2.d(300): Error: array operation `[1] * 6` without destination memory not allowed
223 fail_compilation/fail_arrayop2.d(303): Error: cannot modify expression `[1] * 6` because it is not an lvalue
224 fail_compilation/fail_arrayop2.d(304): Error: cannot modify expression `[1] * 6` because it is not an lvalue
225 fail_compilation/fail_arrayop2.d(307): Error: `[1] * 6` is not of integral type, it is a `int[]`
226 fail_compilation/fail_arrayop2.d(308): Error: `[1] * 6` is not of integral type, it is a `int[]`
227 fail_compilation/fail_arrayop2.d(309): Error: `[1] * 6` is not of integral type, it is a `int[]`
228 fail_compilation/fail_arrayop2.d(312): Error: array operation `[1] * 6` without destination memory not allowed
229 fail_compilation/fail_arrayop2.d(313): Error: array operation `[1] * 6` without destination memory not allowed
230 fail_compilation/fail_arrayop2.d(316): Error: array operation `[1] * 6` without destination memory not allowed
231 fail_compilation/fail_arrayop2.d(317): Error: array operation `[1] * 6` without destination memory not allowed
232 fail_compilation/fail_arrayop2.d(318): Error: array operation `[1] * 6` without destination memory not allowed
233 fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed
234 fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed
235 fail_compilation/fail_arrayop2.d(321): Error: array operation `[1] * 6` without destination memory not allowed
238 // Test all expressions, which can take arrays as their operands but cannot be a part of array operation.
241 struct S
{ int[] a
; }
247 { auto r
= [[1] * 6]; } // ArrayLiteralExp
248 { auto r
= [[1] * 6 :
249 [1] * 6]; } // AssocArrayLiteralExp
252 // StructLiteralExp.elements <- preFunctionParameters in CallExp
253 { auto r
= S([1] * 6); }
255 // NewExp.arguments <- preFunctionParameters
256 { auto r
= new S([1] * 6); }
259 //auto ti = typeid([1] * 6);
260 //auto foo(T)(T t) {}
261 //foo(typeid([1] * 6));
262 //auto a = [typeid([1] * 6)];
265 { auto r
= ([1] * 6, 1); }
269 cast(char)1 + "abc"[]);
271 // CallExp.arguments <- preFunctionParameters
274 // AddrExp, if a CT-known length slice can become an TypeSarray lvalue in the future.
275 { auto r
= &(([1] * 6)[0..2]); }
277 // PtrExp, *([1] * 6).ptr is also invalid -> show better diagnostic
278 { auto r
= *([1] * 6); }
283 // TypeDArray.dotExp, cannot check in ArrayLengthExp.semantic()
284 { auto r
= (6 * da[]).length
; }
287 { auto x1
= (da[] * 6)[1]; }
306 // Shl, Shr, UshrExp - e1, e2 --> checkIntegralBin
307 { auto r
= ([1] * 6) << 1; }
308 { auto r
= ([1] * 6) >> 1; }
309 { auto r
= ([1] * 6) >>> 1; }
311 // AndAnd, OrOrExp - e1, e2
312 { auto r
= sa
[0..5] && [1] * 6; }
313 { auto r
= sa
[0..5] ||
[1] * 6; }
315 // Cmp, Equal, IdentityExp - e1, e2
316 { auto r
= sa
[0..5] <= [1] * 6; }
317 { auto r
= sa
[0..5] == [1] * 6; }
318 { auto r
= sa
[0..5] is [1] * 6; }
320 // CondExp - econd, e1, e2
321 { auto r
= [1] * 6 ?
[1] * 6 : [1] * 6; }
326 fail_compilation/fail_arrayop2.d(342): Error: array operation `[1] * 6` without destination memory not allowed
327 fail_compilation/fail_arrayop2.d(345): Error: array operation `[1] * 6` without destination memory not allowed
328 fail_compilation/fail_arrayop2.d(348): Error: array operation `[1] * 6` without destination memory not allowed
329 fail_compilation/fail_arrayop2.d(349): Error: array operation `[1] * 6` without destination memory not allowed
330 fail_compilation/fail_arrayop2.d(350): Deprecation: `[1] * 6` has no effect
331 fail_compilation/fail_arrayop2.d(350): Error: array operation `[1] * 6` without destination memory not allowed
332 fail_compilation/fail_arrayop2.d(353): Error: array operation `[1] * 6` without destination memory not allowed
333 fail_compilation/fail_arrayop2.d(356): Error: array operation `[1] * 6` without destination memory not allowed
334 fail_compilation/fail_arrayop2.d(359): Error: array operation `"str"[] + cast(immutable(char))1` without destination memory not allowed
335 fail_compilation/fail_arrayop2.d(367): Error: CTFE internal error: non-constant value `"uvt"`
336 fail_compilation/fail_arrayop2.d(367): Error: `"uvt"[] - '\x01'` cannot be interpreted at compile time
339 // Test all statements, which can take arrays as their operands.
340 void test15407stmt() {
341 // ExpStatement - exp
344 // DoStatement - condition
345 do {} while ([1] * 6);
347 // ForStatement - condition, increment
348 for ([1] * 6; // init == ExpStatement
352 // ForeachStatement - aggr -> lowered to ForStatement
353 foreach (e
; [1] * 6) {}
355 // IfStatement condition
358 // SwitchStatement - condition
364 // CaseStatement - exp
367 case "uvt"[] - 1: break;