blob: a5633b8c13bbeecd5058939b98d513383b152296 [file] [log] [blame]
// REQUIRED_ARGS: -preview=dip1008
// https://issues.dlang.org/show_bug.cgi?id=19317
class MyException: Exception {
static int numInstances;
this(string msg) {
super(msg);
++numInstances;
}
~this() {
--numInstances;
}
}
void main() {
assert(MyException.numInstances == 0);
try
throw new MyException("oops");
catch(MyException _)
assert(MyException.numInstances == 1);
assert(MyException.numInstances == 0);
try
throw new MyException("oops I did it again");
catch(MyException)
assert(MyException.numInstances == 1);
assert(MyException.numInstances == 0);
}