www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3607] New: Problems with struct opEquals and const

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 11 2009
next sibling parent d-bugmail puremagic.com writes:
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: -------
Sep 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3607


Don <clugdbug yahoo.com.au> changed:

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



*** 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: -------
Sep 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 01 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3607




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: -------
Dec 01 2010
prev sibling parent d-bugmail puremagic.com writes:
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



*** 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: -------
Jun 12 2011