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
public class Main {
public int get() {
int a = 1, b = 2;
if ((a == 1) && (b == 2)) {
return c;
}
return -1;
}
}
The declaration of the variable c was removed, the transformation causes compilation errors. Changing the order of the applied rules yields the correct results.
I debugged the problem and the rule RemoveUselessVariables does not find any usages for the variable c. I then had a look at the rule CollapsibleIfStatements, where the then-block of the inner if is cloned and set as then-block of the parent-if:
In clone() the child statements and expressions are cloned as well. When the VariableDeclaration for c is cloned only the variable name and the definition are taken over; the usages however are not cloned (this seems to be the case for all sibling classes). The then-block then contains statements with erased semantic analysis. The block seems to get passed to the next rules which then lacks the required information.
The text was updated successfully, but these errors were encountered:
Applying a non-semantic rule before a semantic rule can break that semantic rule. For the source
the transformation chain
results in the source code
The declaration of the variable
c
was removed, the transformation causes compilation errors. Changing the order of the applied rules yields the correct results.I debugged the problem and the rule
RemoveUselessVariables
does not find any usages for the variablec
. I then had a look at the ruleCollapsibleIfStatements
, where the then-block of the innerif
is cloned and set as then-block of the parent-if
:In
clone()
the child statements and expressions are cloned as well. When theVariableDeclaration
forc
is cloned only the variable name and the definition are taken over; the usages however are not cloned (this seems to be the case for all sibling classes). The then-block then contains statements with erased semantic analysis. The block seems to get passed to the next rules which then lacks the required information.The text was updated successfully, but these errors were encountered: