Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Verifier crashes on a `for` loop whose body is an empty statement (`for (...) ;`)

Abierto Apto para principiantes
#395 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
tooling

Línea de trabajo

El fallo está en visitCtFor en src/main/java/liquidjava/processor/refinement_checker/RefinementTypeChecker.java, donde una lambda llama a getElements sobre CtFor.getBody() alrededor de la línea 628; la misma ruta pasa por visitLoop alrededor de la línea 658. Empieza leyendo cómo se consume el cuerpo del bucle allí y luego ejecuta el reproductor del issue, que tiene un cuerpo vacío ;. Está terminado cuando ese reproductor imprime Correct! Passed Verification. y una prueba de bucle existente sigue pasando.

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

Descripción

bug

Impact: verification stops with an internal error on any for loop whose body is an empty statement (;).

Description

for (...; ...; ...) ; has no body block: CtFor.getBody() is null, and RefinementTypeChecker.visitCtFor calls getElements on it (RefinementTypeChecker.java:628). Nothing in the loop needs a refinement, so an empty body could be checked as an empty block.

Minimal reproducer

public class Repro {
    static int total(int[] counts) {
        int total = 0;
        for (int i = 0; i < counts.length; total += counts[i], i++)
            ;
        return total;
    }
}

Expected

Correct! Passed Verification.

Actual

Exception in thread "main" java.lang.RuntimeException: 
Error while checking CtMethodImpl
  on total(int[] counts) { 
  at Repro.java:2
  with 
Error while checking CtBlockImpl
  on { 
  at Repro.java:2
  with 
Error while checking CtForImpl
  on for (int i = 0; i < counts.length; total += counts[i], i++) 
  at Repro.java:4
  with Cannot invoke "spoon.reflect.code.CtStatement.getElements(spoon.reflect.visitor.Filter)" because the return value of "spoon.reflect.code.CtFor.getBody()" is null
...
Caused by: java.lang.NullPointerException: Cannot invoke "spoon.reflect.code.CtStatement.getElements(spoon.reflect.visitor.Filter)" because the return value of "spoon.reflect.code.CtFor.getBody()" is null
	at liquidjava.processor.refinement_checker.RefinementTypeChecker.lambda$visitCtFor$4(RefinementTypeChecker.java:628)
	at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitLoop(RefinementTypeChecker.java:658)
	at liquidjava.processor.refinement_checker.RefinementTypeChecker.visitCtFor(RefinementTypeChecker.java:623)

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

Real-world file that hits it

  • for (int i = 0; i < updateCount.length; cnt += updateCount[i], i++) ; — tejeswarp/tungsten-replicator (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). Each file is verified on its own, as a user would verify one file of a project, so the project's other classes and its dependencies are not on the classpath.

Lenguaje dominante
Java
Estrellas
69
Forks
36
Merge medio
2 d 1 h
PR fusionados (30 d)
35

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.