The Regex Checker should support flow refinements based on Matcher.groupCount()
checks:
if (mat.matches()) {
if (mat.groupCount() > 0) {
System.out.println("Group: " + mat.group(1));
}
}
The call of mat.group(1) is guaranteed to succeed by the guards.
The Checker currently reports an error:
MatcherGroupCount.java:22: error: invalid groups parameter 1. Only 0 groups are
guaranteed to exist for mat.
System.out.println("Group: " + mat.group(1));
^
1 error
A test file is in checker-framework/checkers/tests/regex/MatcherGroupCount.java
(For bonus points: the Regex Checker currently only recognizes int literals;
once the Value Checkers are integrated, this could be extended accordingly.)
Original issue reported on code.google.com by wdi...@gmail.com on 14 Dec 2013 at 6:59
Original issue reported on code.google.com by
wdi...@gmail.com
on 14 Dec 2013 at 6:59