[Issue 7164] New: Can't inline function literal
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Dec 25 19:31:52 PST 2011
    
    
  
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 at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-12-25 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: -------
    
    
More information about the Digitalmars-d-bugs
mailing list