This code should be compilable. import std.functional; void main() { version(Workaround) typeof(toDelegate(&main)) dgDummy; // <- Code is compilable if this line is enabled. static assert(is(typeof(toDelegate(&main)))); // NG: false }
Reduced test case: private struct DelegateFaker(F) { template GeneratingPolicy() {} enum WITH_BASE_CLASS = __traits(hasMember, GeneratingPolicy!(), "x"); } auto toDelegate(F)(F fp) { alias DelegateFaker!F Faker; } void main() { version(pass) { pragma(msg, typeof(toDelegate(&main))); static assert(is(typeof(toDelegate(&main)))); } else { static assert(is(typeof(toDelegate(&main)))); } }
https://github.com/D-Programming-Language/dmd/pull/566
https://github.com/D-Programming-Language/dmd/commit/9642adfe1705a4db07cb374bbf363fdc5f7af859 https://github.com/D-Programming-Language/dmd/commit/c0c645ad89169ff6478ee73c63b2181e081f030f