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




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


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




------- Comment #2 from matti.niemenmaa+dbugzilla iki.fi  2008-04-25 04:29
-------
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




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


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


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




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




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


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


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


--- Comment #11 from Kenji Hara <k.hara.pg gmail.com> 2011-09-16 03:44:11 PDT
---
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


--- Comment #12 from Stewart Gordon <smjg iname.com> 2012-02-08 09:13:29 PST ---
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



--- Comment #13 from Steven Schveighoffer <schveiguy yahoo.com> 2012-02-08
10:24:14 PST ---
(In reply to comment #12)
 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


--- Comment #14 from Walter Bright <bugzilla digitalmars.com> 2012-02-08
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



--- Comment #15 from Stewart Gordon <smjg iname.com> 2012-04-08 10:23:47 PDT ---
(In reply to comment #14)
 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



--- Comment #16 from Walter Bright <bugzilla digitalmars.com> 2012-04-08
11:32:23 PDT ---
(In reply to comment #15)
 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



--- Comment #17 from github-bugzilla puremagic.com 2012-07-08 19:39:59 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/271085b2d368b5b3046ef95798ae9aec50ab1484
Merge pull request #387 from 9rnsr/constApply

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



--- Comment #18 from github-bugzilla puremagic.com 2012-07-22 21:47:25 PDT ---
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
Merge pull request #278 from 9rnsr/rev_const

Minimal reverting of Issue 1824 - Object not const correct

--- Comment #19 from github-bugzilla puremagic.com 2012-07-22 21:47:25 PDT ---
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
Merge pull request #702 from 9rnsr/rev_const

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



--- Comment #18 from github-bugzilla puremagic.com 2012-07-22 21:47:25 PDT ---
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
Merge pull request #278 from 9rnsr/rev_const

Minimal reverting of Issue 1824 - Object not const correct

--- Comment #19 from github-bugzilla puremagic.com 2012-07-22 21:47:25 PDT ---
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
Merge pull request #702 from 9rnsr/rev_const

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



--- Comment #20 from github-bugzilla puremagic.com 2012-07-22 21:49:05 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/724b077b3b34dbf92ce391177141854255a6e104
Merge pull request #1053 from 9rnsr/revert_const

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