diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tangotests/nested2.d	Fri Jun 13 05:47:28 2008 +0200
@@ -0,0 +1,32 @@
+module tangotests.nested2;
+
+extern(C) int printf(char*, ...);
+
+void main()
+{
+    int var = 2;
+
+    void exec(void delegate() dg)
+    {
+        printf("var = %d\n", var);
+        dg();
+    }
+
+    void foo()
+    {
+        printf("var = %d\n", var);
+        assert(var == 5);
+    }
+
+    void bar()
+    {
+        printf("var = %d\n", var);
+        var += 3;
+        exec(&foo);
+    }
+
+    printf("var = %d\n", var);
+    exec(&bar);
+
+    return 0;
+}
\ No newline at end of file