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

Deterministic toString check doesn't work with ternary #178

Open
jwaataja opened this issue Apr 3, 2020 · 0 comments
Open

Deterministic toString check doesn't work with ternary #178

jwaataja opened this issue Apr 3, 2020 · 0 comments
Assignees

Comments

@jwaataja
Copy link
Collaborator

jwaataja commented Apr 3, 2020

The check performed by @RequiresDetToString sometimes prints an error when it shouldn't, such as in this class,

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

public class C {
    public static void f() {
        System.out.printf("%s", true ? "" : "");
    }
}

I get the error

C.java:5: error: [nondeterministic.tostring] java.lang.Object does not override toString() deterministically
        System.out.printf("%s", true ? "" : "");
                         ^

This doesn't happen if we just write System.out.printf("%s", "");. It must have something to do with the ternary operator in this case.

jwaataja added a commit to jwaataja/checker-framework that referenced this issue Jun 25, 2020
@jwaataja jwaataja self-assigned this Jun 25, 2020
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