]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/ice12501.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / ice12501.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/ice12501.d(29): Error: function ice12501.foo (int value) is not callable using argument types (int, int)
5 fail_compilation/ice12501.d(29): Error: function ice12501.foo (int value) is not callable using argument types (int, int)
6 fail_compilation/ice12501.d(43): Error: template instance ice12501.reduce!(foo, foo).reduce!(Tuple!(int, int), int[]) error instantiating
7 ---
8 */
9
10 struct Tuple(T...)
11 {
12 alias Types = T;
13 T field;
14 alias field this;
15 }
16 Tuple!A tuple(A...)(A args) { return typeof(return)(args); }
17
18 template reduce(fun...)
19 {
20 auto reduce(Args...)(Args args)
21 {
22 alias seed = args[0];
23 alias r = args[1];
24 Args[0] result = seed;
25 for (; r.length != 0; r = r[1..$])
26 {
27 foreach (i, Unused; Args[0].Types)
28 {
29 result[i] = fun[i](result[i], r[0]);
30 }
31 }
32 return result;
33 }
34 }
35
36 int foo(int value)
37 {
38 return value;
39 }
40
41 void main()
42 {
43 reduce!(foo, foo)(tuple(0, 0), [ 1 ]);
44 }