Issue with dmd 2.066, alias this, and sort

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 28 03:38:11 PDT 2014


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.


More information about the Digitalmars-d-learn mailing list