[Issue 12569] Better error message for std.algorithm.reduce used with two functions and a scalar seed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 13 12:01:28 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12569

--- Comment #1 from monarchdodra at 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.

--


More information about the Digitalmars-d-bugs mailing list