Bug 2409 – property is not called

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-10-09T10:17:00Z
Last change time
2015-06-09T01:20:17Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dfj1esp02

Comments

Comment #0 by dfj1esp02 — 2008-10-09T10:17:26Z
There is similar bug 2159. There property is called instead of taking function's address. I encountered an opposite issue: property is not called and compiler tries to apply operator to the property itself rather than to object returned by the property. Seems like compiler desides on its own, when to call property and when not. This is very confusing. ----------------- alias void delegate(Object,void*) EventHandler; class A { MulticastDelegate ClickHandlers; MulticastDelegate Click() { return ClickHandlers; } } void fun() { A a=new A(); EventHandler hnd; a.Click+=hnd; //rejected should call MulticastDelegate.opAddAssign a.Click()+=hnd; //accepted a.ClickHandlers+=hnd; //works (field) } struct MulticastDelegate { EventHandler opAddAssign(EventHandler hnd) { //...add handler to invocationList... return hnd; } } ------------------
Comment #1 by sandford — 2009-08-04T05:47:08Z
Another similar use case: void delegate(int) func(); void main() { func(1); }
Comment #2 by destructionator — 2012-08-04T09:38:06Z
Now that there's the @property decoration, I think it's about time we make this actually work right. It's been wrong a long time. I think whenever the compiler sees an expression that is an @property, it should immediately rewrite it into the function call, so address of, call, etc. all go on the return value. Functions without @property can remain the way they are now.
Comment #3 by k.hara.pg — 2013-04-07T04:34:08Z
OP code works in 2.063a (git head: aa767b0d7fe1616010a6caf205918f29aa4560a1)