www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9840] New: Methods in templates should likely not require the 'this' reference

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 puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



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: -------
Mar 30 2013