Thread overview
[Issue 3656] New: delegate should specify 'this' decorations
Mar 19, 2011
Don
December 28, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3656

           Summary: delegate should specify 'this' decorations
           Product: D
           Version: 2.036
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: schveiguy@yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2009-12-28 06:34:17 PST ---
Note, this bug applies to 2.037, but for some reason it's not in the version list.

import std.stdio;

class A
{
    void f() {}
}

void main()
{
    const A a = new A;
    auto g = &a.f;
    writefln("%s", typeof(g).stringof);
    g();
}

This outputs:

void delegate()

First, the line:

auto g = &a.f;

shouldn't compile because f cannot be called on a.  However, even if f is
changed to a const function, the output is still "void delegate()", it should
be "void delegate() const".

This breaks const correctness without a cast, because I can call g, but not a.f.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 28, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3656



--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2009-12-28 08:45:23 PST ---
Note that more important than const decoration propogation is shared propogation, since the compiler should call the delegate differently.

Note also that with contravariance for delegates as identified in bug 3075 would make this a lot easier to deal with.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3656


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-03-18 23:35:58 PDT ---
This seems to be a duplicate of bug 1983

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3656


Steven Schveighoffer <schveiguy@yahoo.com> changed:

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


--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-06-12 11:28:15 PDT ---
Yes, it's a dupe.  I also realize now that identifying the decorations for the this pointer makes delegates a lot less useful, so they shouldn't specify this decorations.  I think even in the case where the function is shared, it's not important, the member function should handle the shared semantics properly.

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

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