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
{{ message }}
Repository navigation
Variable 'this' could not be found when a ghost-refined method is called on another call's result #478
A method whose parameter refinement mentions the receiver's ghost (index < size(this)) fails with Not Found Error: Variable 'this' could not be found when it is called on another call's result, as in m.get("k").get(0). With a local variable in between, the verifier reports the expected refinement error (the receiver's size is unknown), so only the chained form breaks.
importjava.util.ArrayList;
importjava.util.HashMap;
publicclassClient {
publicstaticvoidmain(String[] args) {
HashMap<String, ArrayList<String>> m = newHashMap<>();
ArrayList<String> l = newArrayList<>();
l.add("a");
m.put("k", l);
Strings = m.get("k").get(0); // Not Found Error: Variable 'this' could not be found
}
}
Expected: a refinement error at get(0) (the list comes from HashMap.get, so its size is unknown), the same one the verifier gives for ArrayList<String> x = m.get("k"); x.get(0);: index == 0 is not a subtype of index >= 0 && index < size(x).
Chained reads from a map of lists are common. One of five mined GitHub methods using ArrayList does this: Minimum-Vertex-Cover MVC.readGraph, while (lineNum <= Integer.parseInt(result.get("0").get(0))). The error stops verification of the whole method, and its message points at this, which the user never wrote.
Found while checking mined client code against JDK specs (liquid-java/co-specification, verifier probe V38).
Activity