mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
32 lines
667 B
D
32 lines
667 B
D
// 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);
|
|
}
|