"Fossies" - the Fresh Open Source Software Archive

Member "dmd-2.089.0/test/fail_compilation/ice12501.d" (2 Nov 2019, 1182 Bytes) of package /linux/misc/dmd-2.089.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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