This is a language design question:
Do you think unreachable code (in programming languages in general) should raise a warning (i.e. "report problem and compile anyway") or an error ("refuse to compile")?
Personally I strongly feel it should be an error: if the programmer writes a piece of code, it should always be with the intention of actually running it in some scenario. But the C# compiler for example seems to disagree with this and merely reports a warning.
Note: I realize good dead code detection is a very difficult problem, but that is not the focus of this question.
Here are some examples of pieces of code where some statements are clearly unreachable:
return;
foo();
--
throw new Exception();
foo();
--
if (...) {
return;
} else {
throw new Exception();
}
foo();