[Issue 9840] New: Methods in templates should likely not require the 'this' reference

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 30 13:10:04 PDT 2013


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

           Summary: Methods in templates should likely not require the
                    'this' reference
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-03-30 13:10:03 PDT ---
struct S
{
    template T()
    {
        bool get() { return true; }
        enum bool T = get();
    }
}

void main()
{
    S s;

    S.T!();  // NG
    s.T!();  // NG
}

The 'get' function cannot be called even if we have a this reference. But I
don't think the above should require a this reference. It's an inner method
that doesn't touch any fields of struct S.

The workaround is to mark the inner function as static.

-- 
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