You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the code below is type checked, the function dead is marked with a Missing return statement error. This is incorrect and should be the dead code warning/error for the println statement.
I've executed this with rascal version 0.18.0.202004041615
module DeadCode
import IO;
int dead() {
while(true) {
return 0;
};
println("This is dead code");
}
The text was updated successfully, but these errors were encountered:
Hi @kevinvandervlist thanks for the report. You are right that it would be desirable to mark the println statement as dead code. But can it be done by the type checker? It all depends on the analysis of the condition of the while statement. Here it is trivial and this exceptional case could be added. In general, the type checker cannot decide whether the condition will be true or false without executing it. I will think about it what it requires to add such special casing.
BTW, we would prefer to have these and similar issues in the Rascal repo and reserve the issues here for TypePal specific issues.
Okay, thanks, will keep using rascal repo from now on.
I agree obviously, and it's not feasible it is to always do this, especially in general.
However, the current approach of marking this as Missing return code, especially as an error, also seems to far off the actual situation. This reduces the value quite a bit I'd say.
It's obviously up to you, but a simple heuristic like 'there is a return statement within the while, so we might exit, therefore we mark this as a warning' seems to be much more helpful compared to the current error.
If the code below is type checked, the function
dead
is marked with aMissing return statement
error. This is incorrect and should be thedead code
warning/error for theprintln
statement.I've executed this with rascal version
0.18.0.202004041615
The text was updated successfully, but these errors were encountered: