Open RustanLeino opened 4 years ago
Rustan, Does the Dafny compiler infrastructure have any cross-language reachability analysis to apply here? As the compiler does not produce a Java AST, but just the textual output through the TargetWriters, it seems the analysis must be performed on the Dafny AST.
Note that it is the JVM that forbids unreachable code, not the Java compiler itself. So we will have to hack something into the compiler to catch the cases of unreachableness that Java does, or else just tell the Java users - don't do that.
The following code is legal in Dafny:
It compiles to more-or-less the same code in Java. However, the Java compiler produces an error about the unreachable statement (the one after the
break
), which causes the Dafny compiler to crash.Repro: