Soundness: an error in an enum or record static initializer hides errors in later types

Abierto
#402 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
compilers

Línea de trabajo

Start with visitCtRecord and visitCtEnum in RefinementTypeChecker, and compare them with the per-member catches in visitCtMethod and visitCtConstructor. Reproduce with the two files in demo/ from the issue: the enum static initializer error currently stops the check before Z.m. Done means both the Z.use(-1) error in Mode and the n = -1 error in Z.m are reported, for enums, records and the class field and initializer cases.

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

Descripción

bug

Impact: violations are silently not reported (the verdict is still a failure, but only for the first error). Found while investigating #342.

Description

An error raised in a static initializer of an enum or record stops checking of every later type in the package. visitCtRecord and visitCtEnum in RefinementTypeChecker have no per-member catch, so the error reaches RefinementProcessor.processPackage. With a class the same code reports both errors. Also, for classes, an error in a field initializer or initializer block reaches the catch in visitCtClass, and the rest of that class is not checked.

Minimal reproducer (both files in one directory demo/)

package demo;

enum Mode {
    A;
    static { Z.use(-1); }
}
package demo;

import liquidjava.specification.Refinement;

class Z {
    static void use(@Refinement("_ > 0") int x) {}
    void m() {
        @Refinement("_ > 0") int n = -1;
    }
}

Expected

Two Refinement Errors: Z.use(-1) in Mode, and n = -1 in Z.m.

Actual (main ad055b49)

Only the first one. Same with record Mode(int a) { static { Z.use(-1); } }. With class Mode { static { Z.use(-1); } } both errors are reported.

Possible fix

Per-member catches like the ones in visitCtMethod / visitCtConstructor, for initializers and field initializers of classes, enums and records.

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.