Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upper Bound Checker does not use @MinLen annotations #3207

Closed
mernst opened this issue Mar 30, 2020 · 0 comments · Fixed by #3502
Closed

Upper Bound Checker does not use @MinLen annotations #3207

mernst opened this issue Mar 30, 2020 · 0 comments · Fixed by #3502

Comments

@mernst
Copy link
Member

mernst commented Mar 30, 2020

Consider the following code, which is checked in as checker/tests/index/Issue3207.java:

import org.checkerframework.checker.index.qual.LTLengthOf;
import org.checkerframework.common.value.qual.MinLen;

public class Issue3207 {

  void m(int @MinLen(1) [] arr) {
    @LTLengthOf("arr") int j = 0;
  }

  void m2(int @MinLen(1) [] @MinLen(1) [] arr) {
    @LTLengthOf("arr[0]") int j = 0;
  }

  void m3(int @MinLen(1) [] @MinLen(1) [] arr) {
    int @MinLen(1) [] arr0 = arr[0];
    @LTLengthOf("arr0") int j = 0;
  }
}

The Index Checker issues the following error for method m2:

Issue3207.java:15: error: [assignment.type.incompatible] incompatible types in assignment.
        @LTLengthOf("arr[0]") int j = 0;
                                      ^
  found   : @UpperBoundUnknown int
  required: @LTLengthOf(value="arr[0]") int
1 error

I believe the problem is in UpperBoundVisitor.relaxedCommonAssignment. Its documentation lists two heuristics, but the first one seems to apply only to NEW_ARRAY expressions rather than all expressions of type @MinLen(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant