is this a bug with writeln / std.algorithm.remove?

arturg var.spool.mail700 at gmail.com
Fri Feb 16 12:15:07 UTC 2018


On Friday, 16 February 2018 at 11:45:21 UTC, arturg wrote:
> this code fails to compile:
>
>     void delegate(void*) dg;
>     void delegate(void*)[] dgs = [dg, dg, dg];
>     dgs.writeln;
>     dgs.remove(1).writeln();
>
> if you comment out dgs.writeln; it works as expected,
> it works if you use other types then void*:
>
>     void delegate(int*) dg;
>     void delegate(int*)[] dgs = [dg, dg, dg];
>     dgs.writeln;
>     dgs.remove(1).writeln();
>
>
> the compiler is DMD64 D Compiler v2.078.2 and the error message 
> is:
>
> /usr/include/dlang/dmd/std/algorithm/mutation.d(1929): Error: 
> template std.algorithm.mutation.moveAll cannot deduce function 
> from argument types !()(void delegate(void*)[], void 
> delegate(void*)[]), candidates are:
> /usr/include/dlang/dmd/std/algorithm/mutation.d(1455):        
> std.algorithm.mutation.moveAll(InputRange1, 
> InputRange2)(InputRange1 src, InputRange2 tgt) if 
> (isInputRange!InputRange1 && isInputRange!InputRange2 && 
> is(typeof(move(src.front, tgt.front))))
> empty.d(9): Error: template instance 
> std.algorithm.mutation.remove!(cast(SwapStrategy)2, void 
> delegate(void*)[], int) error instantiating

running all dmd version on run.dlang.io
gives me this output:

Up to      2.075.1: Success with output:
-----
[void delegate(void*), void delegate(void*), void delegate(void*)]
[void delegate(void*), void delegate(void*)]
-----

Since      2.076.1: Failure with output:
-----
/path/to/dmd.linux/dmd2/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1929): Error: template std.algorithm.mutation.moveAll cannot deduce function from argument types !()(void delegate(void*)[], void delegate(void*)[]), candidates are:
/path/to/dmd.linux/dmd2/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1455):        std.algorithm.mutation.moveAll(InputRange1, InputRange2)(InputRange1 src, InputRange2 tgt) if (isInputRange!InputRange1 && isInputRange!InputRange2 && is(typeof(move(src.front, tgt.front))))
onlineapp.d(7): Error: template instance 
std.algorithm.mutation.remove!(cast(SwapStrategy)2, void 
delegate(void*)[], int) error instantiating
-----



More information about the Digitalmars-d-learn mailing list