Skip to content

Verifier crashes when an enum (or class) constant is compared in an if #302

Description

@CatarinaGamboa

Description

Comparing a value with a constant accessed through a type, directly in an if condition, crashes verification. Seen with a user enum (format == Format.JPG) and with JDK constants (mode != ImageWriteParam.MODE_COPY_FROM_METADATA). Assigning the comparison to a boolean local first works.

Minimal reproducer (no refinements needed)

public class Repro {
    enum Format { JPG, PNG }

    static String extension(Format format) {
        if (format == Format.JPG) {
            return "jpg";
        }
        return "png";
    }

    public static void main(String[] args) {
        System.out.println(extension(Format.PNG));
    }
}

Expected

Correct! Passed Verification.

Actual

Error while checking CtIfImpl
  on if (format == Format.JPG) {
  with Cannot invoke "liquidjava.rj_language.Predicate.substituteVariable(String, String)" because "elemRef" is null

Reproduced on main at 8816186 (liquidjava-verifier 0.0.35), and on 0.0.33.

Context

Found while turning real open-source Java code into study examples for the error-message study: real code hits this constantly, so the examples have to be rewritten around it or cannot be verified. Affects 2 of our examples.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions