D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7164 - Can't inline function literal
Summary: Can't inline function literal
Status: RESOLVED DUPLICATE of issue 5499
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-25 19:31 UTC by Andrej Mitrovic
Modified: 2011-12-27 11:37 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-12-25 19:31:50 UTC
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
Comment 1 Martin Nowak 2011-12-27 11:37:15 UTC

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