Jump to page: 1 2
Thread overview
[Issue 1824] New: Object not const correct
Feb 09, 2008
d-bugmail
Apr 25, 2008
d-bugmail
Apr 25, 2008
d-bugmail
Dec 01, 2008
d-bugmail
Feb 03, 2009
d-bugmail
May 27, 2009
Sobirari Muhomori
May 27, 2009
Sobirari Muhomori
Apr 12, 2011
Kenji Hara
Sep 16, 2011
Kenji Hara
Feb 08, 2012
Stewart Gordon
Feb 08, 2012
Walter Bright
Apr 08, 2012
Stewart Gordon
Apr 08, 2012
Walter Bright
February 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1824

           Summary: Object not const correct
           Product: D
           Version: 2.010
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: caron800@googlemail.com


Just thought I'd let you know that the following functions in Object are not const correct in D2:

    void print();
    string toString();
    int opEquals(Object o);
    int opCmp(Object o);
    hash_t toHash();

They should be:

    const
    {
        void print();
        string toString();
        int opEquals(const(Object) o);
        int opCmp(const(Object) o);
        hash_t toHash();
    }

(And for that matter, opEquals should probably return bool, but that's less
important).

And just to make life really interesting, if you do

    class A
    {
        const
        {
            int opEquals(Object o) { /*...*/ }
        }
    }

You get the error message

function A.opEquals (Object) does not match parameter types (Object)


-- 

April 25, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1824


caron800@googlemail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
            Version|2.010                       |2.013




------- Comment #1 from caron800@googlemail.com  2008-04-25 02:15 -------
Raising the priority of this to critical because it hasn't been fixed yet.

The following will not compile:

    import std.stdio;

    class A {}
    const A a = new A;
    const A b = new A;

    void main()
    {
        if (a == b) writefln("equal");
    }

The error is
Error: a.opEquals can only be called on a mutable object, not const(A)


-- 

April 25, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1824


matti.niemenmaa+dbugzilla@iki.fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Version|2.013                       |2.010




------- Comment #2 from matti.niemenmaa+dbugzilla@iki.fi  2008-04-25 04:29 -------
Please keep the version field as the oldest known affected version.


-- 

December 01, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1824


maxmo@pochta.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |2400




------- Comment #4 from maxmo@pochta.ru  2008-12-01 08:41 -------
Adding const code duplication bug as dependency, since overrides of these methods can depend on other methods possibly non-const, which will lead to code duplication.


-- 

February 03, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1824





------- Comment #5 from maxmo@pochta.ru  2009-02-03 06:22 -------
Additional note: many classes in object.di are declared with mutable members. Shouldn't ClassInfo, TypeInfo etc. be invariant?


-- 

May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Sobirari Muhomori <maxmo@pochta.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davidl@126.com




--- Comment #6 from Sobirari Muhomori <maxmo@pochta.ru>  2009-05-27 06:22:58 PDT ---
*** Issue 3027 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: -------
May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Sobirari Muhomori <maxmo@pochta.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |someanon@yahoo.com




--- Comment #7 from Sobirari Muhomori <maxmo@pochta.ru>  2009-05-27 06:24:24 PDT ---
*** Issue 2899 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: -------
June 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@kyllingen.net
          Component|Phobos                      |druntime
         AssignedTo|nobody@puremagic.com        |sean@invisibleduck.org


--- Comment #8 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-06-21 10:44:32 PDT ---
As of DMD 2.020, this is a druntime issue, not a Phobos one.

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com


--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2011-04-12 03:13:52 PDT ---
*** Issue 3916 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: -------
April 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1824



--- Comment #10 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-04-12 06:35:27 PDT ---
Just a note regarding bug 3916, the issue extends into the global opEquals function for object, it must also be const correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2