Andreas Dangel
-
2016-12-18
- Ruleset / Rule: --> DFA
While testing a custom DFA-based rule, I noticed that the DFA engine sometimes misses definitions and references.
To reproduce, just use the rule designer UI and consider the Data Flow Analysis for the following piece of Java code:
public class Test { public void method() { for (int i = 0; i < 10; i++) { System.out.println(i); } for (int i = 0; i < 10; i++) { System.err.println(i); } } }
You will notice that the second loop, which has its own version of variable i
, shows neither definitions nor references of i
. This is certainly a bug, which affects every rule based on DFA.
If one changes i
to j
in the second loop, DFA behaves more or less as expected, although I wouldn't consider i
being defined twice by the first loop either.