struct Fug { bool opEquals(ref const Fug y) const { return false; } } struct Fig { // line 29 Fug f; bool opEquals(Tdummy=void)(ref const Fig y) const { return false; } bool opEquals(T: int)(T y) const { return false; } } void main() { Fig fx, fy; if (fx==2) {} } --- And the error message is nonsense: bug.d(29): Error: function bug.Fig.opEquals conflicts with template bug.Fig.opEq uals(Tdummy = void) at bug.d(31) Worked in 2.036. -------- // Workaround is to change Fug opEquals to: bool opEquals(Tdummy=void)(ref const Fug y) const
Problem is in struct.c, StructDeclaration::semantic(), line 497: it tries to find an opEquals() function, and if not present, it builds one. It should look for a template opEquals() also. If there's a template opEquals, then creating a non-template opEquals will inevitably cause a naming conflict. Dsymbol *s = search_function(this, Id::eq); FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL; + TemplateDeclaration *td = s ? s->isTemplateDeclaration() : NULL; if (fdx) { eq = fdx->overloadExactMatch(tfeqptr); if (!eq) fdx->error("type signature should be %s not %s", tfeqptr->toChars(), fdx->type->toChars()); } - if (!eq) + if (!eq && !td) eq = buildOpEquals(sc2);
http://www.dsource.org/projects/dmd/changeset/564