Skip to content

null literals are rejected, so any null check stops verification #301

Description

@CatarinaGamboa

Description

Any null literal (x = null, x == null, new IIOImage(img, null, null)) produces Error: Null literals are not supported, and the rest of the file is not verified. Null checks are everywhere in real code.

Minimal reproducer

public class Repro {
    public static void main(String[] args) {
        String name = null;
        if (name == null) {
            System.out.println("no name");
        }
    }
}

Expected

At least no error: until nulls are supported in refinements, treat a null literal (and comparisons with it) as carrying no information, the same as an unknown value.

Actual

Running LiquidJava on: <repro dir>

Error: Null literals are not supported
2 |     public static void main(String[] args) {
3 |         String name = null;
4 |         if (name == null) {
  |                     ^^^^
5 |             System.out.println("no name");
6 |         }

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. It affects 6 of 12 examples (blocks one, and forces rewrites in five, e.g. X s = null; try { s = new X(); ... } finally { if (s != null) s.close(); }).

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