Thread overview
[Issue 3607] New: Problems with struct opEquals and const
Dec 11, 2009
Richard Webb
[Issue 3607] Regression(2.037) Problems with struct opEquals and const
Sep 22, 2010
Don
Sep 22, 2010
Don
Dec 01, 2010
Don
Dec 01, 2010
Richard Webb
Jun 13, 2011
yebblies
December 11, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3607

           Summary: Problems with struct opEquals and const
           Product: D
           Version: 2.036
          Platform: x86
               URL: http://www.digitalmars.com/webnews/newsgroups.php?art_
                    group=digitalmars.D.learn&article_id=18407
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: webby@beardmouse.org.uk


--- Comment #0 from Richard Webb <webby@beardmouse.org.uk> 2009-12-11 06:04:18 PST ---
While trying to build the Juno library with DMD 2.037, i got a bunch or errors like:

juno\com\core.d(295): Error: function juno.com.core.GUID.opEquals type
signature should be const bool(ref const(GUID)) not bool(GUID other)

Which can be replicated with:
////////////////////////////////
struct Foo
{
    bool opEquals(Foo f) const
    {
        return true;
    }
}

void Bar()
{
    Foo f;
}
////////////////////////////////

As mentioned in the post @
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=18407,
the error seems to have been caused by changeset 260, which was made to fix bug
3433.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3607


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|Problems with struct        |Regression(2.037) Problems
                   |opEquals and const          |with struct opEquals and
                   |                            |const
           Severity|normal                      |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3607


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-09-22 03:40:56 PDT ---
*** Issue 4289 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3607


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Regression(2.037) Problems  |Problems with struct
                   |with struct opEquals and    |opEquals and const
                   |const                       |
           Severity|regression                  |enhancement


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-12-01 03:12:08 PST ---
The error message is correct, and the code compiles if you change the signature
to ref const Foo. The spec clearly states:
"If structs declare an opEquals member function, it should follow the following
form:

struct S {
    int opEquals(ref const S s) { ... }
}"


A key point in the forum discussion, which was missing from the bug report was this comment:

> I think it should be allowed to have a signature like this:
> bool opEquals(T other) const
> inside T as long as T can be implicitly cast from const to mutable.

Changing to an enhancement request.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3607



--- Comment #3 from Richard Webb <webby@beardmouse.org.uk> 2010-12-01 06:45:44 PST ---
Shouldn't the spec say 'bool opEquals' instead of 'int opEquals' ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3607


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #4 from yebblies <yebblies@gmail.com> 2011-06-12 22:44:02 PDT ---
*** This issue has been marked as a duplicate of issue 3659 ***

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