[Issue 1841] Closure detection doesn't work when variable is used in a nested function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 27 00:03:38 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1841
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-07-27 00:03:36 PDT ---
Here's a clearer test case. The second assert fails.
Closure detection works correctly if you change the delegate literal to:
return delegate int() { int x=heap; return nested_func(); };
---------------------
//import std.stdio;
int delegate() Foo()
{
int stack;
int heap=3;
// writeln("&stack=",&stack," &heap=",&heap);
int nested_func()
{
++heap;
return heap;
}
return delegate int() { return nested_func(); };
}
void main()
{
auto z = Foo();
auto p = Foo();
assert(z()==4); // OK
p();
assert(z()==5); // fails
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list