typetools / typetools/checker-framework
Unable to infer @NonNegative property of elements in a double dimensional array.
Open
Nobody has claimed this yet.
enhancement
False Positive (false warning or imprecision)
Index
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Consider the following code:
import org.checkerframework.checker.index.qual.NonNegative;
class Issue2502{
public void check_it(@NonNegative int x, @NonNegative int y){
@NonNegative int a[][] = {{x},{y}};
}
}
Run it by typing in the terminal:
javac -processor index Issue2502.java
Output:
Issue2502.java:4: error: [assignment.type.incompatible] incompatible types in assignment.
@NonNegative int a[][] = {{x},{y}};
found : @LowerBoundUnknown int @LowerBoundUnknown [] @LowerBoundUnknown []
required: @NonNegative int @LowerBoundUnknown [] @LowerBoundUnknown []
1 error
Each value assigned in the array is non negative, but the checker still indicates error.
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
Reproduce the reported case from Issue2502.java by running javac -processor index Issue2502.java. Start by tracing the index checker’s handling of nested array initializers and qualifier inference; done means the shown @NonNegative declaration no longer produces an assignment.type.incompatible error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100