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

Ouverte
#402 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
62/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Java
Étoiles
73
Forks
38
Merge moyen
12 h 32 min
PR mergées (30 j)
45

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de liquid-java/liquidjava

Toutes les issues de liquid-java/liquidjava

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.