digitalmars.D.learn - Issue with dmd 2.066, alias this, and sort
- rcor (10/10) Aug 27 2014 I've tried to express my problem in a mostly minimal example here:
- bearophile (9/21) Aug 27 2014 It compiles if you use:
- rcor (9/18) Aug 27 2014 Thanks bearophile, that does make the gist compile. However, in
- monarch_dodra (4/27) Aug 28 2014 Seems like a library bug. Unsure if DMD or phobos for this one,
- monarch_dodra (5/25) Aug 28 2014 DMD issue:
- monarch_dodra (2/4) Aug 28 2014 https://github.com/D-Programming-Language/phobos/pull/2472
I've tried to express my problem in a mostly minimal example here: https://gist.github.com/murphyslaw480/d4a5f857a104bcf62de1 The class Point has an alias this to its own property 'feature()', which returns a reference to a private member. When I try to sort a Point[], DMD fails with "mutable method feature is not callable on const object". I'm not actually using the property 'feature()' or the alias this in the sorting, so it seems like it shouldn't interfere. That being said, I'm still slightly const-challenged so maybe its an error on my part. However, the above example compiles fine with DMD 2.065.0-3.
Aug 27 2014
rcor:I've tried to express my problem in a mostly minimal example here: https://gist.github.com/murphyslaw480/d4a5f857a104bcf62de1 The class Point has an alias this to its own property 'feature()', which returns a reference to a private member. When I try to sort a Point[], DMD fails with "mutable method feature is not callable on const object". I'm not actually using the property 'feature()' or the alias this in the sorting, so it seems like it shouldn't interfere. That being said, I'm still slightly const-challenged so maybe its an error on my part. However, the above example compiles fine with DMD 2.065.0-3.It compiles if you use: property auto feature() const pure nothrow { return _feature; } Otherwise I get strange errors like: ...\dmd2\src\phobos\std\exception.d(986,31): Error: pure function 'std.exception.doesPointTo!(Point, Point, void).doesPointTo' cannot call impure function 'temp.Point.feature' Bye, bearophile
Aug 27 2014
On Wednesday, 27 August 2014 at 21:43:40 UTC, bearophile wrote:It compiles if you use: property auto feature() const pure nothrow { return _feature; } Otherwise I get strange errors like: ...\dmd2\src\phobos\std\exception.d(986,31): Error: pure function 'std.exception.doesPointTo!(Point, Point, void).doesPointTo' cannot call impure function 'temp.Point.feature' Bye, bearophileThanks bearophile, that does make the gist compile. However, in my own code, I'm getting all sorts of complaints from other modules about mutable methods not being callable on const objects (the alias this surfaces some methods that are mutable). I guess its my own fault for not being diligent about const-correctness, but it seems odd that sort would care about the constness of feature() when it is sorting based on x and y. Do you know if there is a reason for this?
Aug 27 2014
On Wednesday, 27 August 2014 at 21:43:40 UTC, bearophile wrote:rcor:Seems like a library bug. Unsure if DMD or phobos for this one, but there is definitely a phobos bug to be fixed anyways. I'll investigate both.I've tried to express my problem in a mostly minimal example here: https://gist.github.com/murphyslaw480/d4a5f857a104bcf62de1 The class Point has an alias this to its own property 'feature()', which returns a reference to a private member. When I try to sort a Point[], DMD fails with "mutable method feature is not callable on const object". I'm not actually using the property 'feature()' or the alias this in the sorting, so it seems like it shouldn't interfere. That being said, I'm still slightly const-challenged so maybe its an error on my part. However, the above example compiles fine with DMD 2.065.0-3.It compiles if you use: property auto feature() const pure nothrow { return _feature; } Otherwise I get strange errors like: ...\dmd2\src\phobos\std\exception.d(986,31): Error: pure function 'std.exception.doesPointTo!(Point, Point, void).doesPointTo' cannot call impure function 'temp.Point.feature' Bye, bearophile
Aug 28 2014
On Thursday, 28 August 2014 at 10:38:12 UTC, monarch_dodra wrote:On Wednesday, 27 August 2014 at 21:43:40 UTC, bearophile wrote:DMD issue: https://issues.dlang.org/show_bug.cgi?id=13392 Phobos issue: http://forum.dlang.org/thread/uignsankcumgmhwpoead forum.dlang.org#post-uignsankcumgmhwpoead:40forum.dlang.orgrcor: It compiles if you use: property auto feature() const pure nothrow { return _feature; } Otherwise I get strange errors like: ...\dmd2\src\phobos\std\exception.d(986,31): Error: pure function 'std.exception.doesPointTo!(Point, Point, void).doesPointTo' cannot call impure function 'temp.Point.feature' Bye, bearophileSeems like a library bug. Unsure if DMD or phobos for this one, but there is definitely a phobos bug to be fixed anyways. I'll investigate both.
Aug 28 2014
On Thursday, 28 August 2014 at 10:54:47 UTC, monarch_dodra wrote:Phobos issue: http://forum.dlang.org/thread/uignsankcumgmhwpoead forum.dlang.org#post-uignsankcumgmhwpoead:40forum.dlang.orghttps://github.com/D-Programming-Language/phobos/pull/2472
Aug 28 2014