Comment #0 by var.spool.mail700 — 2018-02-16T14:17:29Z
this code fails to compile:
void main(){
import std.algorithm;
void delegate(void*) dg;
void delegate(void*)[] dgs = [dg, dg, dg];
dgs.writeln;
dgs.remove(1).writeln();
}
if you comment out the line with dgs.writeln;
or if the delegate uses a different type it works as expected.
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
forum discussion:
https://forum.dlang.org/post/[email protected]
Comment #1 by schveiguy — 2018-02-16T14:42:04Z
A couple more notes:
Putting a pragma(msg, isInputRange!(typeof(dgs))) before the remove line seems to make it succeed to compile.
Removing the writeln after the remove also makes it succeed.
Comment #2 by var.spool.mail700 — 2018-02-17T14:55:00Z
Comment #4 by var.spool.mail700 — 2018-02-20T19:13:35Z
std.container and std.variant are also affected by this, none of them workd with a void delegate(void*).
Comment #5 by var.spool.mail700 — 2018-02-20T22:17:03Z
(In reply to ArturG from comment #4)
> std.container and std.variant are also affected by this, none of them workd
> with a void delegate(void*).
ok was able to find the code that broke std.container for me
template Temp(alias fun)
{
enum foo1 = [__traits(getFunctionAttributes, fun)]; // fails
//enum foo1 = __traits(getFunctionAttributes, fun); // works
}
void test(){}
void main(string[] args)
{
import std.stdio, std.container;
Temp!test.foo1.writeln;
void delegate(void*) dg;
SList!(void delegate(void*)) list;
list.insert(dg);
list[].writeln;
}
Comment #6 by var.spool.mail700 — 2018-02-20T23:14:24Z
(In reply to ArturG from comment #5)
> (In reply to ArturG from comment #4)
> > std.container and std.variant are also affected by this, none of them workd
> > with a void delegate(void*).
>
> ok was able to find the code that broke std.container for me
>
> template Temp(alias fun)
> {
> enum foo1 = [__traits(getFunctionAttributes, fun)]; // fails
> //enum foo1 = __traits(getFunctionAttributes, fun); // works
> }
>
> void test(){}
>
> void main(string[] args)
> {
> import std.stdio, std.container;
>
> Temp!test.foo1.writeln;
>
> void delegate(void*) dg;
> SList!(void delegate(void*)) list;
> list.insert(dg);
> list[].writeln;
> }
reduced it abit furter:
import std.meta, std.conv;
void delegate(void*) vdg;
enum s = [Alias!("asd")].to!string;
SList!(void delegate(void*)) list;
list.insert(vdg);
list.writeln;
Comment #7 by var.spool.mail700 — 2018-02-21T11:28:21Z
(In reply to ArturG from comment #6)
> (In reply to ArturG from comment #5)
> > (In reply to ArturG from comment #4)
> > > std.container and std.variant are also affected by this, none of them workd
> > > with a void delegate(void*).
> >
> > ok was able to find the code that broke std.container for me
> >
> > template Temp(alias fun)
> > {
> > enum foo1 = [__traits(getFunctionAttributes, fun)]; // fails
> > //enum foo1 = __traits(getFunctionAttributes, fun); // works
> > }
> >
> > void test(){}
> >
> > void main(string[] args)
> > {
> > import std.stdio, std.container;
> >
> > Temp!test.foo1.writeln;
> >
> > void delegate(void*) dg;
> > SList!(void delegate(void*)) list;
> > list.insert(dg);
> > list[].writeln;
> > }
>
> reduced it abit furter:
>
> import std.meta, std.conv;
> void delegate(void*) vdg;
> enum s = [Alias!("asd")].to!string;
> SList!(void delegate(void*)) list;
> list.insert(vdg);
> list.writeln;
this fails since dmd 2.067.1
void main(string[] args) {
import std.conv, std.container, std.stdio;
void delegate(void*) vdg;
auto s = [5f].to!(double[]);
SList!(void delegate(void*)) list;
list.insert(vdg);
list.writeln;
}
Comment #8 by var.spool.mail700 — 2018-02-21T16:25:29Z
(In reply to ArturG from comment #7)
> (In reply to ArturG from comment #6)
> > (In reply to ArturG from comment #5)
> > > (In reply to ArturG from comment #4)
> > > > std.container and std.variant are also affected by this, none of them workd
> > > > with a void delegate(void*).
> > >
> > > ok was able to find the code that broke std.container for me
> > >
> > > template Temp(alias fun)
> > > {
> > > enum foo1 = [__traits(getFunctionAttributes, fun)]; // fails
> > > //enum foo1 = __traits(getFunctionAttributes, fun); // works
> > > }
> > >
> > > void test(){}
> > >
> > > void main(string[] args)
> > > {
> > > import std.stdio, std.container;
> > >
> > > Temp!test.foo1.writeln;
> > >
> > > void delegate(void*) dg;
> > > SList!(void delegate(void*)) list;
> > > list.insert(dg);
> > > list[].writeln;
> > > }
> >
> > reduced it abit furter:
> >
> > import std.meta, std.conv;
> > void delegate(void*) vdg;
> > enum s = [Alias!("asd")].to!string;
> > SList!(void delegate(void*)) list;
> > list.insert(vdg);
> > list.writeln;
>
> this fails since dmd 2.067.1
>
> void main(string[] args) {
> import std.conv, std.container, std.stdio;
> void delegate(void*) vdg;
> auto s = [5f].to!(double[]);
> SList!(void delegate(void*)) list;
> list.insert(vdg);
> list.writeln;
> }
anything that somehow calls dup fails:
void main()
{
import std.container, std.array;
dup([4]);
//Appender!(int[]) ap;
SList!(void delegate(void*)) list;
}
Comment #9 by razvan.nitu1305 — 2018-12-18T15:18:20Z
I'm not sure this is a dmd issue. For example, this compiles just fine:
void main(){
import std.algorithm;
//import std.stdio;
void delegate(void*) dg;
void delegate(void*)[] dgs = [dg, dg, dg];
//dgs.writeln;
dgs.remove(1);
}
However uncommenting the commented lines issues the error. I suspect something was broken in the innards of writeln.
Comment #10 by robert.schadek — 2024-12-01T16:32:45Z