typetools / typetools/checker-framework

missing exceptional edges in CFG for for-each loops

Open
#3,585 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dataflow
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

For a for-each loop like:

List<String> list = ...;
for (String s: list) {
  ...
}

The CFG includes the relevant calls to iterator(), hasNext() and next() for the loop. But, the corresponding MethodInvocationNodes for these calls appear inside RegularBlocks rather than ExceptionBlocks. Hence, the possibility of any of these calls throwing an exception is not accounted for. This could lead to checker unsoundness, though I do not immediately have an example of that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the CFG construction for enhanced for-each loops and inspect how MethodInvocationNodes for iterator(), hasNext(), and next() are placed in RegularBlocks versus ExceptionBlocks. Verify the behavior with a representative Java for-each example. Done means the CFG accounts for exceptions from these calls and the relevant behavior is covered by tests, if an existing CFG test location can be found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.