typetools / typetools/checker-framework
Imprecise refinement in Value Checker in loops
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Consider the following loop:
void test() {
for (int i = 0; i < 12; i++) {
@IntRange(from = 0, to = 12) int j = i;
}
}
I would expect this code to typecheck. Instead, the following error is issued:
error: [assignment.type.incompatible] incompatible types in assignment.
@IntRange(from = 0, to = 12) int j = i;
^
found : @IntRange(from=0, to=127) int
required: @IntRange(from=0, to=12) int
1 error
This is very strange behavior - I don't know why the Value Checker might think that 0 to 12 -> 0 to 127.
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.
Research direction
Start by reproducing the Java loop in the Value Checker and trace how its loop refinement derives the reported 0-to-127 range. Compare that result with the expected 0-to-12 range; done means the snippet typechecks and the regression is covered by an appropriate test.
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
- 35/100