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

Loop variable doesn't get type refined correctly. #201

Open
t-rasmud opened this issue Aug 28, 2020 · 0 comments
Open

Loop variable doesn't get type refined correctly. #201

t-rasmud opened this issue Aug 28, 2020 · 0 comments

Comments

@t-rasmud
Copy link
Owner

Consider the test case:

import org.checkerframework.checker.determinism.qual.PolyDet;

public class TestLoopVar {
    static void test(@PolyDet int cnt) {
        for (int i = 0; i < cnt; i++) {
            @PolyDet String s1 = String.format("Instruction %d:\n", i);
        }
        for (@PolyDet int j = 0; j < cnt; j++) {
            @PolyDet String s1 = String.format("Instruction %d:\n", j);
        }
    }
}

Running the determinism checker with the command 'javac -processor determinism checker/tests/determinism/TestLoopVar' results in the following error incorrectly:

checker/tests/determinism/TestLoopVar.java:6: error: [assignment.type.incompatible] incompatible types in assignment.
            @PolyDet String s1 = String.format("Instruction %d:\n", i);
                                              ^
  found   : @NonDet String
  required: @PolyDet String
1 error

However, the checker doesn't show the error in the second for loop (Notice that the type of variable j is explicitly annotated as @PolyDet).

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

No branches or pull requests

1 participant