False error: a break nested inside a switch case forgets that path's state (Found shows true)

Abierto
#499 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
testing-qa

Línea de trabajo

Start by reading the switch and control flow handling added in #497, especially how loop exits collect state at break and yield. Trace the nested-break example through the verifier and identify where each exit context should join the case end states. Done means the example compiles without a state refinement error and the reported true path is preserved correctly.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Follow-up to #494 / #497. With switch cases modelled, a break nested inside a case (for example inside an if) is not followed: the state at that break is dropped, so after the switch the verifier knows nothing about that path. Correct code is rejected, and the message shows a bare true.

@StateSet({"closed", "open"})
class Door {
    @StateRefinement(to = "closed(this)") Door() {}
    @StateRefinement(from = "closed(this)", to = "open(this)") void open() {}
    @StateRefinement(from = "open(this)", to = "closed(this)") void close() {}
}

class NestedBreak {
    // Every path opens the door before leaving the switch, so close() is fine
    static void enter(int k, boolean fast) {
        Door d = new Door();
        switch (k) {
            case 1:
                if (fast) {
                    d.open();
                    break;
                }
                d.open();
                break;
            default:
                d.open();
        }
        d.close();
    }
}

On the #497 branch (432a508c):

State Refinement Error: found k == 1 ? true : open(d) but expected open(d)
31 |         d.close();
Hints:
  - d can be in closed or open here, depending on the path taken, and no sequence of calls moves all of them to open. Make d reach this line in the same state on every path

Expected: no error. The true means "forgotten", which users are not told, and the hint describes a split that does not exist.

Fix direction: record the context at each nested break / yield and join it with the cases' end states, as loops already do for their exits.

Not needed for the error-message study (no study exercise has this shape after a switch).

Lenguaje dominante
Java
Estrellas
73
Forks
38
Merge medio
12 h 32 min
PR fusionados (30 d)
45

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de liquid-java/liquidjava

Todos los issues de liquid-java/liquidjava

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.