Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail_opover.d

raw
1 // REQUIRED_ARGS: -o-
2
3 /*
4 TEST_OUTPUT:
5 ---
6 fail_compilation/fail_opover.d(39): Error: no `[]` operator overload for type `object.Object`
7 $p:object.d$(110): perhaps define `auto opIndex() {}` for `object.Object`
8 fail_compilation/fail_opover.d(43): Error: no `[]` operator overload for type `TestS`
9 fail_compilation/fail_opover.d(41): perhaps define `auto opIndex() {}` for `fail_opover.test1.TestS`
10 fail_compilation/fail_opover.d(55): Error: no `[]` operator overload for type `S`
11 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S`
12 fail_compilation/fail_opover.d(56): Error: no `[]` operator overload for type `S`
13 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S`
14 fail_compilation/fail_opover.d(57): Error: no `[1..2]` operator overload for type `S`
15 fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S`
16 fail_compilation/fail_opover.d(58): Error: no `[]` operator overload for type `S`
17 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S`
18 fail_compilation/fail_opover.d(59): Error: no `[]` operator overload for type `S`
19 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S`
20 fail_compilation/fail_opover.d(60): Error: no `[1..2]` operator overload for type `S`
21 fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S`
22 fail_compilation/fail_opover.d(61): Error: no `[]` operator overload for type `S`
23 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S`
24 fail_compilation/fail_opover.d(62): Error: no `[]` operator overload for type `S`
25 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S`
26 fail_compilation/fail_opover.d(63): Error: no `[1..2]` operator overload for type `S`
27 fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S`
28 fail_compilation/fail_opover.d(64): Error: no `[]` operator overload for type `S`
29 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex() {}` for `fail_opover.test2.S`
30 fail_compilation/fail_opover.d(65): Error: no `[]` operator overload for type `S`
31 fail_compilation/fail_opover.d(48): perhaps define `auto opIndex(int) {}` for `fail_opover.test2.S`
32 fail_compilation/fail_opover.d(66): Error: no `[1..2]` operator overload for type `S`
33 fail_compilation/fail_opover.d(48): perhaps define `auto opSlice(int lower, int upper) {}` for `fail_opover.test2.S`
34 ---
35 */
36 void test1()
37 {
38 Object m;
39 m[] = error;
40
41 struct TestS {}
42 TestS s;
43 s[] = error;
44 }
45
46 void test2()
47 {
48 struct S
49 {
50 void func(int) {}
51 alias func this;
52 }
53 S s;
54 // The errors failing aliasthis access need to be gagged for better error messages.
55 s[]; // in ArrayExp::op_overload()
56 s[1]; // ditto
57 s[1..2]; // ditto
58 +s[]; // in UnaExp::op_overload()
59 +s[1]; // ditto
60 +s[1..2]; // ditto
61 s[] = 3; // in AssignExp::semantic()
62 s[1] = 3; // ditto
63 s[1..2] = 3; // ditto
64 s[] += 3; // in BinAssignExp::op_overload()
65 s[1] += 3; // ditto
66 s[1..2] += 3; // ditto
67 }