MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / testOpApply.d
blob8d6c736e5af944b5b8344a0dbb1d7384d9ca74d2
1 /+
2 TEST_OUTPUT:
3 ---
4 fail_compilation/testOpApply.d(27): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @safe)` matches both:
5 fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)`
6 and:
7 fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)`
8 ---
9 +/
11 struct SameAttr
13 int opApply(int delegate(int) @system dg) @system
15 return 0;
18 int opApply(int delegate(int) @system dg) @safe
20 return 0;
24 void testSameAttr() @safe
26 SameAttr sa;
27 foreach (int i; sa) {}
31 TEST_OUTPUT:
32 ---
33 fail_compilation/testOpApply.d(104): Error: `testOpApply.SameAttr.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches both:
34 fail_compilation/testOpApply.d(13): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)`
35 and:
36 fail_compilation/testOpApply.d(18): `testOpApply.SameAttr.opApply(int delegate(int) @system dg)`
37 ---
39 #line 100
41 void testSameAttr() @system
43 SameAttr sa;
44 foreach (int i; sa) {}
48 TEST_OUTPUT:
49 ---
50 fail_compilation/testOpApply.d(217): Error: `sa.opApply` matches more than one declaration:
51 fail_compilation/testOpApply.d(203): `int(int delegate(int) dg)`
52 and:
53 fail_compilation/testOpApply.d(208): `int(int delegate(string) dg)`
54 fail_compilation/testOpApply.d(217): Error: cannot uniquely infer `foreach` argument types
55 ---
57 #line 200
59 struct DifferentTypes
61 int opApply(int delegate(int) dg)
63 return 0;
66 int opApply(int delegate(string) dg)
68 return 0;
72 void testDifferentTypes()
74 DifferentTypes sa;
75 foreach (i; sa) {}
79 TEST_OUTPUT:
80 ---
81 fail_compilation/testOpApply.d(317): Error: `sa.opApply` matches more than one declaration:
82 fail_compilation/testOpApply.d(303): `int(int delegate(int) dg)`
83 and:
84 fail_compilation/testOpApply.d(308): `int(int delegate(long) dg)`
85 fail_compilation/testOpApply.d(317): Error: cannot uniquely infer `foreach` argument types
86 ---
88 #line 300
90 struct CovariantTypes
92 int opApply(int delegate(int) dg)
94 return 0;
97 int opApply(int delegate(long) dg)
99 return 0;
103 void testCovariantTypes()
105 CovariantTypes sa;
106 foreach (i; sa) {}
110 See https://issues.dlang.org/show_bug.cgi?id=21683
112 TEST_OUTPUT:
114 fail_compilation/testOpApply.d(420): Error: `sa.opApply` matches more than one declaration:
115 fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)`
116 and:
117 fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)`
118 fail_compilation/testOpApply.d(420): Error: cannot uniquely infer `foreach` argument types
121 #line 400
123 struct DifferentQualifiers
125 int x;
126 int opApply(int delegate(int) dg)
128 x = 1;
129 return 0;
132 int opApply(int delegate(ref int) dg)
134 x = 2;
135 return 0;
139 void testDifferentQualifiers()
141 DifferentQualifiers sa;
142 foreach (i; sa) {}
146 TEST_OUTPUT:
148 fail_compilation/testOpApply.d(504): Error: `sa.opApply` matches more than one declaration:
149 fail_compilation/testOpApply.d(404): `int(int delegate(int) dg)`
150 and:
151 fail_compilation/testOpApply.d(410): `int(int delegate(ref int) dg)`
152 fail_compilation/testOpApply.d(504): Error: cannot uniquely infer `foreach` argument types
155 #line 500
157 void testDifferentQualifiersRef()
159 DifferentQualifiers sa;
160 foreach (ref i; sa) {}