Bug 7164 – Can't inline function literal

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-12-25T19:31:00Z
Last change time
2011-12-27T11:37:15Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-12-25T19:31:50Z
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 by code — 2011-12-27T11:37:15Z
*** This issue has been marked as a duplicate of issue 5499 ***