www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2409

           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
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2409


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() {
        func(1);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2409


Adam D. Ruppe <destructionator gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator gmail.com


--- Comment #2 from Adam D. Ruppe <destructionator gmail.com> 2012-08-04
09:38:06 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2409


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2013-04-07 04:34:08 PDT ---
OP code works in 2.063a (git head: aa767b0d7fe1616010a6caf205918f29aa4560a1)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 07 2013