Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

False error: a local declared inside try is "not found" at a call in finally

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
compilers

調査の方向性

Start by reproducing the report: save the Repro class from the issue and run LiquidJava on it to see the Not Found Error at input.close() in the finally. The cause is that the state of input recorded at the end of the try still mentions the block-local length, which is out of scope when the finally checks close(). Done means the repro passes verification and the change does not break the existing tests.

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

説明

bug

With the Barista BufferedInputStream spec (read() returns _ >= -1; read(byte[], int, int) refines its length):

import java.io.*;

public class Repro {
    static int load(InputStream raw, boolean known) throws IOException {
        BufferedInputStream input = new BufferedInputStream(raw);
        try {
            int cost = 0;
            if (known) {
                int length = input.read();
                if (length >= 0) {
                    byte[] nonce = new byte[length];
                    input.read(nonce, 0, length);
                }
            }
            return cost;
        } finally {
            input.close();
        }
    }
}

On main 1c6807be (and 321a7321):

Not Found Error: Variable 'length' could not be found
  input.close();   (in the finally)

length is a block-local of the try; the state of input recorded in the try (after read(nonce, 0, length)) mentions it, and when the finally checks close() against that state, length is out of scope. Expected: Correct! Passed Verification. (out-of-scope locals should be eliminated or kept as fresh variables when the state flows into the finally / after the block).

Found in a real-code example (secrets-for-android FileUtils, a length-prefixed read in try/finally). Since #366 the example's earlier workaround (guarding with a block instead of an early return) no longer avoids it.

主要言語
Java
スター
69
フォーク
36
平均マージ
2日 1時間
マージ済み PR(30日)
35

環境構築

はじめの一歩

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

liquid-java/liquidjava のほかの issue

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

似ている issue

Java の issue をもっと見る

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

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