enum Type { A, B, } struct Foo {} struct Bar { Foo foo; alias foo this; } void main() { Bar bar; test!(Type.A)(bar); // fail test!(Type.A)(cast(Foo)bar); // ok } void test(Type type)(Foo foo) if (type == Type.A) { } void test(Type type)(Foo foo) // comment out and both run ok if (type == Type.B) { } If you remove the second test() template both instantiations in main() will work, which is very odd.
*** This issue has been marked as a duplicate of issue 2778 ***