On 01/27/2016 09:51 AM, Shachar Shemesh wrote:
import std.stdio;
struct RAII {
int num;
~this() {
writefln("Destructed %s", num);
}
}
struct Container {
int num;
RAII raii;
this(int num) {
writefln("Constructing %s", num);
this.num = num;
raii = RAII(num);
if( num==0 )
throw new Exception("Ooops");
}
}
void test(int num) {
try {
auto c = Container(num);
writefln("Point %s", num);
} catch(Exception ex) {
writefln("Caught %s", ex.msg);
}
}
void main()
{
test(1);
test(0);
}
Interesting. It may be worked around, but is arguably a mistake in the
language definition. Have you submitted an issue for this? -- Andrei