typetools / typetools/checker-framework
Index Checker error message refers to out-of-scope variable
Open
Nobody has claimed this yet.
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:
class tryit {
double covariance(final double[] xArray) {
int length = xArray.length;
for (int i = 0; i < length; i++) {}
return ((double) length);
}
}
Compiled it by: javac -processor index tryit.java
Output:
tryit.java:5: warning: [cast.unsafe] "@LessThan("i + 1") int" may not be casted to the type "@LessThan("[error for expression: i + 1; error: Invalid 'i' because identifier not found]") double"
return ((double) length);
^
tryit.java:5: error: [expression.unparsable.type.invalid] Expression invalid in dependent type annotation: [error for expression: i + 1; error: Invalid 'i' because identifier not found]
return ((double) length);
^
1 error
1 warning
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 diagnostic with javac -processor index tryit.java using the example in the issue. Trace the Index Checker code that formats dependent type annotation errors and determine how the out-of-scope i reference is reported; done means the diagnostic no longer produces the misleading variable reference or unparsable-type cascade.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100