Thread overview
[Issue 12569] Better error message for std.algorithm.reduce used with two functions and a scalar seed
April 12, 2014
https://issues.dlang.org/show_bug.cgi?id=12569

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

--
April 13, 2014
https://issues.dlang.org/show_bug.cgi?id=12569

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com

--
April 13, 2014
https://issues.dlang.org/show_bug.cgi?id=12569

--- Comment #1 from monarchdodra@gmail.com ---
(In reply to bearophile_hugs from comment #0)
> This code compiles:
> 
> void main() {
>     import std.algorithm: min, max, reduce;
>     import std.typecons: tuple;
>     dchar c = 'a';
>     reduce!(min, max)(tuple(c, c), "hello"); // OK
> }
> 
> 
> But here I have forgotten to use a 2-tuple as seed for reduce:
> 
> void main() {
>     import std.algorithm: min, max, reduce;
>     import std.typecons: tuple;
>     dchar c = 'a';
>     reduce!(min, max)(c, "hello"); // error
> }

I'd be more worried about passing too *many* arguments, eg:
reduce!(min, max)(tuple(c, c, c), "hello");

Technically, implementation-wise, it *should* pass, but it doesn't make sense to accept it.

Currently, in HEAD, this code ices the compiler. My reduce re-write just accepts it. I'll add your test(s) to it.

--
April 13, 2014
https://issues.dlang.org/show_bug.cgi?id=12569

--- Comment #2 from bearophile_hugs@eml.cc ---
(In reply to monarchdodra from comment #1)

> Currently, in HEAD, this code ices the compiler.

I have filed it as Issue 12574

--
July 28, 2014
https://issues.dlang.org/show_bug.cgi?id=12569

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from bearophile_hugs@eml.cc ---
Fixed: https://github.com/D-Programming-Language/phobos/pull/2060

--