www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7164] New: Can't inline function literal

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7164

           Summary: Can't inline function literal
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



19:31:50 PST ---
I can't tell if this is a bug, I was just playing with it and it's not
important to me:

void foo(alias dg)() {
    dg();
}

void test() {
    foo!({ int x; })();
}

void main() {
    test();
}

$ dmd test.d
ok

$ dmd -inline test.d
test.d(3): Error: function test.test.foo!(delegate pure nothrow  safe void()
{
int x = 0;
}
).foo is a nested function and cannot be accessed from main

Note that if I make it a delegate literal it will compile:

void foo(alias dg)() {
    dg();
}

void test() {
    int y;
    foo!({ int x = y; })();
}

void main() {
    test();
}

$ dmd -inline test.d
ok

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 25 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7164


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dawg dawgfoto.de
         Resolution|                            |DUPLICATE



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

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