Mercurial > projects > ldc
comparison tangotests/nested2.d @ 259:2e652b8ad1fd trunk
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
invalid.
author | lindquist |
---|---|
date | Fri, 13 Jun 2008 05:47:28 +0200 |
parents | |
children | 88252a1af660 |
comparison
equal
deleted
inserted
replaced
258:8dbddae09152 | 259:2e652b8ad1fd |
---|---|
1 module tangotests.nested2; | |
2 | |
3 extern(C) int printf(char*, ...); | |
4 | |
5 void main() | |
6 { | |
7 int var = 2; | |
8 | |
9 void exec(void delegate() dg) | |
10 { | |
11 printf("var = %d\n", var); | |
12 dg(); | |
13 } | |
14 | |
15 void foo() | |
16 { | |
17 printf("var = %d\n", var); | |
18 assert(var == 5); | |
19 } | |
20 | |
21 void bar() | |
22 { | |
23 printf("var = %d\n", var); | |
24 var += 3; | |
25 exec(&foo); | |
26 } | |
27 | |
28 printf("var = %d\n", var); | |
29 exec(&bar); | |
30 | |
31 return 0; | |
32 } |