Skip to content

Soundness: a local copied from an int field follows later writes to the field (int y = f; f = 5 gives y == 5) #565

In review

Description

@CatarinaGamboa

Impact: wrong programs pass verification (unsound).

Description
A local copied from an int field follows later writes to that field, as if it were an alias of the field rather than a copy of its value at that point.

Minimal reproducer

import liquidjava.specification.Refinement;

public class Snap {
    int f;

    void m() {
        int y = f;
        f = 5;
        @Refinement("_ == 5") int k = y;   // y is the old value of f: should be rejected
    }
}

Result on main: Correct! Passed Verification.

A related form, f > 0 ? (f = -1) : 1 checked against _ > 0, also passes.

Expected
The copy keeps the value the field had when it was read. A field read could get a fresh value (an instance) at the read, as locals and parameters already do, so a later write does not change it.

Found in the review of #561.

Activity

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