www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2409] New: property is not called

reply d-bugmail puremagic.com writes:

           Summary: property is not called
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: terranium yandex.ru

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;

Oct 09 2008
parent d-bugmail puremagic.com writes:

Rob Jacques <sandford jhu.edu> changed:

           What    |Removed                     |Added
                 CC|                            |sandford jhu.edu

--- Comment #1 from Rob Jacques <sandford jhu.edu>  2009-08-04 05:47:08 PDT ---
Another similar use case:

void delegate(int) func();
void main() {

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2009