www.digitalmars.com         C & C++   DMDScript  

D - [Bug] Nested function(delegate)

Hello.

Nested function(delegate) can not use correct value of the parent
function(delegate)'s parameters without optimization.
Is this a bug ?

I'm using dmd 0.81.

YT

void call(int d, void delegate(int d) f)
{
 f(d);
}

void main()
{
 call(100, delegate void(int d1){
  printf("%d\n", d1);
  call(200, delegate void(int d2){
   printf("%d\n", d1);
   printf("%d\n", d2);
  });
 });
}

/++++++++++++++++++++++++++++++++++++++
D:\Programming\Tests\D>dmd nested.d
C:\Program Files\DM\dmd\bin\..\..\dm\bin\link.exe
nested,,,user32+kernel32/noi;

D:\Programming\Tests\D>nested
100
4202615
200

D:\Programming\Tests\D>dmd -O nested.d
C:\Program Files\DM\dmd\bin\..\..\dm\bin\link.exe
nested,,,user32+kernel32/noi;

D:\Programming\Tests\D>nested
100
100
200
+++++++++++++++++++++++++++++++++++++++/
Mar 17 2004