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

Aberta
#402 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Java
Estrelas
73
Forks
38
Merge médio
12h 32min
PRs com merge (30d)
45

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de liquid-java/liquidjava

Todas as issues de liquid-java/liquidjava

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.