145
|
1 /*
|
|
2 TEST_OUTPUT:
|
|
3 ---
|
|
4 fail_compilation/fail13574.d(21): Error: '$' is not an lvalue
|
|
5 fail_compilation/fail13574.d(27): Error: '$' is not an lvalue
|
|
6 ---
|
|
7 */
|
|
8
|
|
9 struct Foo
|
|
10 {
|
|
11 void opSlice(size_t a, size_t b) { }
|
|
12 alias opDollar = length;
|
|
13 size_t length;
|
|
14 }
|
|
15
|
|
16 void main()
|
|
17 {
|
|
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);
|
|
23
|
|
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);
|
|
29 }
|