www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1824] New: Object not const correct

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


-- 
Feb 09 2008
next sibling parent d-bugmail puremagic.com writes:
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





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)


-- 
Apr 25 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





-------
Please keep the version field as the oldest known affected version.


-- 
Apr 25 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824


maxmo pochta.ru changed:

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





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.


-- 
Dec 01 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824






Additional note: many classes in object.di are declared with mutable members.
Shouldn't ClassInfo, TypeInfo etc. be invariant?


-- 
Feb 03 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Sobirari Muhomori <maxmo pochta.ru> changed:

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





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


Sobirari Muhomori <maxmo pochta.ru> changed:

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





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: -------
May 27 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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



*** 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: -------
Apr 12 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




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: -------
Apr 12 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824


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

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



---
I have posted patches.

https://github.com/D-Programming-Language/dmd/pull/387
https://github.com/D-Programming-Language/druntime/pull/72
https://github.com/D-Programming-Language/phobos/pull/262

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 16 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |pull
                 CC|                            |smjg iname.com



Any chance of this being folded in for the upcoming 2.058 release?  I am
working on porting my libraries to D2, and it would be good to have this done
and dusted so that I don't have to work around it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




10:24:14 PST ---

 Any chance of this being folded in for the upcoming 2.058 release?
Likely not. I think only fixing regressions is allowed right now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



12:40:03 PST ---
I intend to deal with this at the beginning of the next release cycle. It is a
disruptive change.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824





 I intend to deal with this at the beginning of the next release cycle. It is a
 disruptive change.
Still no sign of it in the 2.059 fix list that has just appeared on the site. Where are you at with it at the moment? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




11:32:23 PDT ---

 Still no sign of it in the 2.059 fix list that has just appeared on the site. 
 Where are you at with it at the moment?
It's a pretty disruptive change. There are some significant issues, like toHash in std.stream is very impure. All that needs to be worked out. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/271085b2d368b5b3046ef95798ae9aec50ab1484


Supplemental changes of druntime/pull/72 - Issue 1824 - Object not const
correct

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/dfc76c8f9b81bb6de647a709e575ff67bc45ffa1
Minimal reverting of Issue 1824 - Object not const correct

https://github.com/D-Programming-Language/druntime/commit/bad7afa37c17d4185fdac02440b27a4f33599579


Minimal reverting of Issue 1824 - Object not const correct


Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/9940579f73d4d540aa22df1d5bce49d61c43855f
Minimal reverting of Issue 1824 - Object not const correct

https://github.com/D-Programming-Language/phobos/commit/9d91e1de2fa7502988762a466a7858fd9599c599


Minimal reverting of Issue 1824 - Object not const correct

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/dfc76c8f9b81bb6de647a709e575ff67bc45ffa1
Minimal reverting of Issue 1824 - Object not const correct

https://github.com/D-Programming-Language/druntime/commit/bad7afa37c17d4185fdac02440b27a4f33599579


Minimal reverting of Issue 1824 - Object not const correct


Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/9940579f73d4d540aa22df1d5bce49d61c43855f
Minimal reverting of Issue 1824 - Object not const correct

https://github.com/D-Programming-Language/phobos/commit/9d91e1de2fa7502988762a466a7858fd9599c599


Minimal reverting of Issue 1824 - Object not const correct

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1824




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/724b077b3b34dbf92ce391177141854255a6e104


Revert all changes for "Issue 1824 - Object not const correct"

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