This compiles and runs with no errors with dmd 2.044: int fun(TElem)(TElem[] arr) { return 10; } alias fun!(char) alternative; // LINE A int alternative(int[] arr) { return 20; } // LINE B void caller(TOp)(TOp op, char[] s) { assert(op(s) == 10); } void main() { caller(&alternative, cast(char[])"abc"); } But if I swap the line A and B: int fun(TElem)(TElem[] arr) { return 10; } int alternative(int[] arr) { return 20; } // LINE B alias fun!(char) alternative; // LINE A void caller(TOp)(TOp op, char[] s) { assert(op(s) == 10); } void main() { caller(&alternative, cast(char[])"abc"); } Then dmd 2.044 shows: test.d(5): Error: cannot implicitly convert expression (s) of type char[] to int[] test.d(8): Error: template instance test.caller!(int function(int[] arr)) error instantiating
Another case, maybe with a different cause: struct Foo(alias f) {} Foo!main baz; void main() {}
Wouldn't the bug be that in first place the "A then B" version works ? It seems that the compiler silently selects the first overload member. I think that AddrExp of an overload-set should not be allowed. This is like assuming that the following code should work: ```d void f(char){} void f(double){} void main() { auto badAddrOfOverSet = &f; f(0.0); } ``` and that is not the case.