| |
 | Posted by d-bugmail | Permalink Reply |
|
d-bugmail 
| http://d.puremagic.com/issues/show_bug.cgi?id=2293
Summary: access instance members from inside delegates
Product: D
Version: 1.034
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla@digitalmars.com
ReportedBy: enzo.petrelli@fastwebnet.it
/***************************
OS: Windows XP Pro SP2 / Vista SP1
Compiler/linker: Digital Mars D Compiler v1.034
Tango/tangobos Lib: tango-0.99.7-bin-win32-dmd.1.033
Compiled with: no compile/link flag
in the first call of the method test of the DelegateTest class
instance,
the delegate defined inside the inner class doesn't access correctly
the
outer class' member miVal
in the second call of te same method, from inside a try/catch block the
outer class' delegate also fails to correctly access the miVal member
***************************/
import tango.core.Exception;
import tango.io.Stdout;
void main()
{
DelegateTest test = new DelegateTest;
Stdout.format("outside try/catch").newline;
test.test();
Stdout.newline.format("inside try/catch").newline;
try
{
test.test();
} catch (Exception)
{
}
}
class DelegateTest
{
int miVal;
void delegate() mpDelegate;
InnerClass moInn;
this()
{
miVal = 5;
moInn = new InnerClass;
mpDelegate = {
Stdout.format("OuterTest.delegate this:{} miVal:{}",
cast(void*) &this, miVal).newline;
};
Stdout.format("OuterTest.ctor this:{} miVal:{}",
cast(void*) &this, miVal).newline;
}
void test()
{
moInn.mpInnerDelegate();
mpDelegate();
}
class InnerClass
{
void delegate() mpInnerDelegate;
this()
{
mpInnerDelegate = {
Stdout.format("InnerClass.delegate this:{}
miVal:{}", cast(void*) &this, miVal).newline;
};
Stdout.format("InnerClass.ctor this:{} miVal:{}",
cast(void*) &this, miVal).newline;
}
}
}
--
|