@property method needs ()
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 24 01:26:14 PST 2014
On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via
Digitalmars-d-learn wrote:
> On Mon, 24 Nov 2014 06:56:08 +0000
> Andre via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> wrote:
>
>> Hi,
>>
>> in following example the @property method needs the ()
>> otherwise compiler error for row 24 is thrown.
>> I cannot judge, whether the compiler behaves correct or not.
>>
>> Kind regards
>> André
>>
>> ---
>>
>> alias fnError = void delegate(string s);
>>
>> interface IfSession
>> {
>> @property fnError addError();
>> }
>>
>> class Session: IfSession
>> {
>> private fnError _addError;
>>
>> @property fnError addError()
>> {
>> return _addError;
>> }
>> }
>>
>> void main()
>> {
>> auto session = new Session();
>> session._addError = delegate(s){};
>>
>> session.addError()("test"); // Works
>> session.addError("test"); // Does not work
>> }
> a known thing. not sure if this is a known *bug* (seems that
> almost
> nobody cares). compiler is obviously wrong here (and i believe
> that
> it's wrong to accept `()` for properties at all), but i don't
> know if
> this will ever be fixed.
There's hope that this will get fixed in the near future:
https://github.com/D-Programming-Language/dmd/pull/2305
More information about the Digitalmars-d-learn
mailing list