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

Aperta
#399 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
40/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Java
Stelle
73
Fork
38
Merge medio
12h 32m
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di liquid-java/liquidjava

Tutte le issue di liquid-java/liquidjava

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.