Bug 1824 – Object not const correct

Status
NEW
Severity
critical
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-02-09T04:44:02Z
Last change time
2024-12-07T13:30:42Z
Keywords
bounty, pull, rejects-valid
Assigned to
Sean Kelly
Creator
Janice Caron
Depends on
9769, 9770, 9771, 9772, 2400
Blocks
3789
Moved to GitHub: dmd#17111 →

Comments

Comment #0 by caron800 — 2008-02-09T04:44:02Z
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)
Comment #1 by caron800 — 2008-04-25T02:15:54Z
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)
Comment #2 by matti.niemenmaa+dbugzilla — 2008-04-25T04:29:09Z
Please keep the version field as the oldest known affected version.
Comment #3 by caron800 — 2008-04-25T04:55:45Z
On 25/04/2008, [email protected] <[email protected]> wrote: > Please keep the version field as the oldest known affected version. Sorry. Didn't realise. Although in this case, the oldest known affected version is, in fact, every single version of D since const was first introduced. I have no idea when that was. J
Comment #4 by dfj1esp02 — 2008-12-01T08:41:47Z
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.
Comment #5 by dfj1esp02 — 2009-02-03T06:22:13Z
Additional note: many classes in object.di are declared with mutable members. Shouldn't ClassInfo, TypeInfo etc. be invariant?
Comment #6 by dfj1esp02 — 2009-05-27T06:22:58Z
*** Issue 3027 has been marked as a duplicate of this issue. ***
Comment #7 by dfj1esp02 — 2009-05-27T06:24:24Z
*** Issue 2899 has been marked as a duplicate of this issue. ***
Comment #8 by post — 2010-06-21T10:44:32Z
As of DMD 2.020, this is a druntime issue, not a Phobos one.
Comment #9 by k.hara.pg — 2011-04-12T03:13:52Z
*** Issue 3916 has been marked as a duplicate of this issue. ***
Comment #10 by schveiguy — 2011-04-12T06:35:27Z
Just a note regarding bug 3916, the issue extends into the global opEquals function for object, it must also be const correct.
Comment #11 by k.hara.pg — 2011-09-16T03:44:11Z
Comment #12 by smjg — 2012-02-08T09:13:29Z
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.
Comment #13 by schveiguy — 2012-02-08T10:24:14Z
(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.
Comment #14 by bugzilla — 2012-02-08T12:40:03Z
I intend to deal with this at the beginning of the next release cycle. It is a disruptive change.
Comment #15 by smjg — 2012-04-08T10:23:47Z
(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?
Comment #16 by bugzilla — 2012-04-08T11:32:23Z
(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.
Comment #17 by github-bugzilla — 2012-07-08T19:39:59Z
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
Comment #18 by github-bugzilla — 2012-07-22T21:47:25Z
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 by github-bugzilla — 2012-07-22T21:47:25Z
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
Comment #20 by github-bugzilla — 2012-07-22T21:49:05Z
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"
Comment #21 by issues.dlang — 2013-11-24T14:02:12Z
Comment #22 by robert.schadek — 2024-12-07T13:30:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17111 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB