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

オープン
#402 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Java
スター
73
フォーク
38
平均マージ
12時間 32分
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

liquid-java/liquidjava のほかの issue

liquid-java/liquidjava の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。