[Issue 6768] Problem with init of struct members in presence of templated opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 12 01:25:57 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6768


Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |verylonglogin.reg at gmail.com
         Resolution|                            |DUPLICATE


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2012-11-12 12:25:48 MSK ---
The issue isn't with `opAssign`. It is because closure isn't detected:
---
import std.stdio;

void setDel()(Foo foo, void delegate() del)
{ foo.del = del; }

class Foo
{
    void delegate() del;

    void f()
    {
        writefln("%X, %X (instance and ref addresses)", cast(void*) this,
&this);
        void g() { writefln("%X, %X (instance and ref addresses from g)",
cast(void*) this, &this); }
        setDel(this, &g);
        writefln("%X (del.ptr)", del.ptr);
    }

    void callDel()
    {
        writefln("+callDel");
        del();
        writefln("-callDel");
    }
}

void main()
{
    auto foo = new Foo();
    foo.f();
    foo.del();
    foo.callDel();
    foo.del();
}
---

Output:
---
A01E70, 12FE58 (instance and ref addresses)
12FE58 (del.ptr)
12FE58, 12FE58 (instance and ref addresses from g)
+callDel
A01E70, 12FE58 (instance and ref addresses from g)
-callDel
12FE58, 12FE58 (instance and ref addresses from g)
---

Created a new issue with corrected title and description.

*** This issue has been marked as a duplicate of issue 8999 ***

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


More information about the Digitalmars-d-bugs mailing list