www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3983] New: Regression(2.037): struct with == can't be member of struct with template opEquals

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3983

           Summary: Regression(2.037): struct with == can't be member of
                    struct with template opEquals
           Product: D
           Version: 2.034
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3983


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



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);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3983


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



23:15:27 PDT ---
http://www.dsource.org/projects/dmd/changeset/564

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 27 2010