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


--- 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: -------
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


--- 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: -------
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


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