MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail13574.d
blob2a9336bc1827d954d369dbf49631dd3d87dc30b0
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail13574.d(21): Error: cannot modify operator `$`
5 fail_compilation/fail13574.d(27): Error: cannot modify operator `$`
6 ---
7 */
9 struct Foo
11 void opSlice(size_t a, size_t b) { }
12 alias opDollar = length;
13 size_t length;
16 void main()
18 Foo foo;
19 foo[0 .. foo.length = 1];
20 assert(foo.length == 1);
21 foo[0 .. $ = 2]; // assigns to the temporary dollar variable
22 //assert(foo.length == 2);
24 int[] arr = [1,2,3];
25 auto x = arr[0 .. arr.length = 1];
26 assert(arr.length == 1);
27 auto y = arr[0 .. $ = 2]; // should also be disallowed
28 //assert(arr.length == 2);