www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12318] New: Nested structs with only templated methods do not capture context

https://d.puremagic.com/issues/show_bug.cgi?id=12318

           Summary: Nested structs with only templated methods do not
                    capture context
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow gmail.com> 2014-03-08
21:07:23 EET ---
////////// test.d /////////
void a(int i)
{
    struct S
    {
        // Uncomment to fix
        //void dummy() {}

        void b()()
        {
            assert(i);
        }
    }

    S s;
    s.b();
    c(s);
}

void c(S)(S s)
{
    s.b();
}
///////////////////////////

Compiler output:

test.d(10): Error: function test.a.S.b!().b cannot access frame of function
test.a
test.d(15): Error: template instance test.a.S.b!() error instantiating

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