statement is not reachable
Qian Xu
quian.xu at stud.tu-ilmenau.de
Thu Mar 5 00:17:08 PST 2009
Hi All,
I have got a warning by compiling ("gdc file -Wall") the following code
----------------------------------------------------------
module unreachable;
class Foo {
this(int i) {}
this(char[] s) {}
this(char[] s, int flag) {
if (flag == 1)
{
this(1);
return;
}
else if (flag == 2)
{
this("hello");
return;
}
throw new Exception("unhandled case");
this(0); // fake
}
}
void main()
{
Foo foo = new Foo("world", 1);
assert(false, "END");
}
-----------------------------------------------------------
The warning is: "statement is not reachable"
If I use switch-case-statment, I can see even an error message:
"constructor calls not allowed in loops or after labels"
So, is my design incorrect, or is the compiler too strict?
--Qian Xu
More information about the Digitalmars-d-learn
mailing list