typetools / typetools/checker-framework
False negative for postconditions with `this` or `#n` in their expression
Open
@smillst is already working on this.
Since Nov 15, 2023.
False Negative (missing warning or unsoundness)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Commit d70dd7436fa9a6706db40be85978ac4dd04d2a18 introduces a false negative, in its use of CFAbstractStore.insertValuePermitNondeterministic(). Consider this test case:
import java.util.Optional;
class PureGetterTest2 {
Optional<String> otherOptional() {
if (Math.random() < 0.5) {
return Optional.ofNullable(null);
} else {
return Optional.of("hello world");
}
}
void foo() {
if (otherOptional().isPresent()) {
// BUG: no "method.invocation" error is issued here.
otherOptional().get();
}
}
}
In a postcondition like @EnsuresPresent("field.method()"), it is correct to permit method() in the expression even if it is not @Deterministic. However, in a postcondition like @EnsuresPresent("#1.method()"), it should not be permitted to substitute in an argument that is not @Deterministic.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.