False error: the bitwise complement `~x` is rejected as an invalid refinement expression

Offen
#399 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
40/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
tooling

Rechercherichtung

The error comes from the refinement-expression parser in the liquidjava verifier, which receives ~x as raw text. Start with the reproducer's clear method and find where the parser rejects unary operators, then see how #360 (bitwise compound assignments) handles the bitwise family. Done means the reproducer passes verification, or the unsupported ~ is left unconstrained without a syntax error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

Impact: correct code is rejected with a syntax error: any use of the bitwise complement operator ~.

Description

~x on an int gives Syntax Error: Invalid refinement expression; the refinement language seems to have no ~, and the expression reaches the parser as text. Until ~ is supported, the result could be left unconstrained (as for other operators the SMT encoding does not cover).

Minimal reproducer

public class Repro {
    static int clear(int flags, int bit) {
        return flags & ~bit;
    }
}

Expected

Correct! Passed Verification.

Actual

Syntax Error: Invalid refinement expression, expected a logical predicate
1 | public class Repro {
2 |     static int clear(int flags, int bit) {
3 |         return flags & ~bit;
  |                        ^^^^
4 |     }
5 | }
Repro.java:3

Reproduced on main at ad055b49 (liquidjava-verifier 0.0.35).

Real-world file that hits it

  • return haystack &= ~needle; — hashsploit/clank (file)

Context

Found while running LiquidJava on the original repository files of 53 real-world typestate and refinement bugs (the files our study exercises were simplified from). The error is reported on code with no refinement of its own, so it is a false error in every file that has the construct. Related: #360 (bitwise compound assignments).

Vorherrschende Sprache
Java
Sterne
73
Forks
38
Ø Merge
12 Std. 32 Min.
Gemergte PRs (30 T.)
45

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus liquid-java/liquidjava

Alle Issues in liquid-java/liquidjava

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.