@property method needs ()

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 24 00:34:55 PST 2014


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141124/44bfd8fe/attachment.sig>


More information about the Digitalmars-d-learn mailing list