Skip to content

A ternary between arrays crashes: Sorts (Array Int Int) and Bool are incompatible #558

In review

Description

@CatarinaGamboa

Description
A conditional expression (c ? x : y) whose branches are arrays crashes the verifier when the result is checked against a length refinement.

Minimal reproducer

import liquidjava.specification.Refinement;

public class Tern {
    static void one(@Refinement("length(a) == 1") int[] a) {}

    static void pick(boolean b) {
        int[] a = b ? new int[1] : new int[1];
        one(a);   // should pass
    }
}

Result on main:

Error: Sorts (Array Int Int) and Bool are incompatible

If the condition mentions args (boolean b = args.length > 0; inside main), the same program instead fails with Not Found Error: Variable 'args' could not be found, which also only happens with the array ternary.

Expected
The program passes: both branches have length 1. A branch array's facts should hold for the result under that branch's condition. Found while reviewing #540.

Activity

  1. added
    bug
    on Nov 24, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions