DMD accept both :
int foo() {
  try {
    throw new Exception("blah");
  } catch(Exception e) {
    return 25;
  }
}

and

int foo() {
  try {
    throw new Exception("blah");
  } catch(Exception e) {
    return 25;
  }

  return 42;
}

Which is it ? What are the rule for the unreachable statment ? It seems that DMD is capable of figuring out that the try never returns, or it would complain about missing return in the first case. But that do not seems consistent with not triggering the unreachable statement in case 2.

I'm working on improving control flow analysis in SDC. My handling of try will error on case 2. Is that the right thing ?

Also, if it is possible to detect that a statement finishes, without triggering a unreachable statement error, is that possible to make it so for static ifs ?

Reply via email to