Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 27, 2014 Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
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. |
August 27, 2014 Re: Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
Posted in reply to rcor | 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 |
August 28, 2014 Re: Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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,
> bearophile
Thanks 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?
|
August 28, 2014 Re: Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Wednesday, 27 August 2014 at 21:43:40 UTC, bearophile wrote:
> 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
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.
|
August 28, 2014 Re: Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | 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: >> rcor: >> >> >> 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 > > 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. 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.org |
August 28, 2014 Re: Issue with dmd 2.066, alias this, and sort | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | 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.org https://github.com/D-Programming-Language/phobos/pull/2472 |
Copyright © 1999-2021 by the D Language Foundation