False error: an escaped char literal ('\r') is rejected as an invalid refinement expression

Aperta
#398 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
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
compilers

Direzione di ricerca

Start from the minimal reproducer in the issue: a Repro.java with if (b == '\r') on a byte should verify, but the refinement parser rejects the escaped char literal with "Invalid refinement expression, expected a logical predicate". The payload does not name the parser file, so find where char literals in refinement expressions are read and how their escape sequences are handled. Done means the reproducer and the '\t' variant both print Correct! Passed Verification., with an existing plain 'a' comparison still passing.

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

Descrizione

bug

Impact: correct code is rejected with a syntax error: any comparison with an escaped char literal ('\r', '\t').

Description

A plain character literal works (c == 'a' passes), but an escape sequence does not: the literal's text seems to reach the refinement parser unescaped (or with a backslash it cannot read), and the parser reports a syntax error on the user's code.

Minimal reproducer

public class Repro {
    static boolean endOfLine(byte b) {
        if (b == '\r') {
            return true;
        }
        return false;
    }
}

Expected

Correct! Passed Verification.

Actual

Syntax Error: Invalid refinement expression, expected a logical predicate
1 | public class Repro {
2 |     static boolean endOfLine(byte b) {
3 |         if (b == '\r') {
  |                  ^^^^
4 |             return true;
5 |         }
Repro.java:3

The same with return c == '\t'; on a char c. Reproduced on main at ad055b49 (liquidjava-verifier 0.0.35).

Real-world file that hits it

  • if (b == '\r') { — 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.

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.