the following program compiled without any particular switch --- class Foo { uint bar(){return 0;} this() { foreach(member; __traits(allMembers, typeof(this))) foreach(overload; __traits(getOverloads, typeof(this), member)) static if (member == "bar") setDg(&overload); } void setDg(uint delegate() dg){} } void main(){} --- crashes DMD and outputs: > Error: delegates are only for non-static functions > Assertion failure: '(int)vindex >= 0' on line 3439 in file 'e2ir.c' - The bug looks highly related to https://issues.dlang.org/show_bug.cgi?id=13920. - The bug only produces a messages since 2.068, previously it was only crashing without any helpful dignostic message.
Lowered importance. Actually the problem seems to come from a lValue/rValue thing because when using an intermediate variable to carry the delegate then this works: --- static if (member == "bar") { auto dg = &overload; // OK with intermediate value setDg(dg); } ---
he knows the topic.
The bug is still there. ICEs are certainly not WONTFIX. Reopening.
The code now leads to a wrong diagnostic "/tmp/temp_7FECD0F3D050.d(9,27): Error: delegates are only for non-static functions" but on the other hand this works class Foo { uint bar(){return 0;} this() { foreach(member; __traits(allMembers, typeof(this))) foreach(overload; __traits(getOverloads, typeof(this), member)) static if (member == "bar") {uint delegate() a = &overload; setDg(a);} } void setDg(uint delegate() dg){} } void main(){}
__traits dont give expressions