Open SasinduDilshara opened 2 years ago
The second return
is only unreachable if the do
clause is guaranteed to be executed at least once. To determine that, you would need to look at whether the iterable to which from
is applied is guaranteed non-empty. But that it is not considered by reachability analysis. The only thing it considers is conditions. https://ballerina.io/spec/lang/master/#section_7.4.3 ought to be explicit about this.
Note that from/do can give rise to unreachable code.
from int _ in arr
where false
do {
foo(); // unreachable
}
Description
Should the statements in a query action do clause affect the (un)reachability of the statements that comes after the query action?.
Spec says
It is a compile error if a statement other than a panic-stmt is not reachable
. According to that this should be give a compile error for unrechability of the code.