False error: a break nested inside a switch case forgets that path's state (Found shows true)

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

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

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

評価

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

調査の方向性

Start by reading the switch and control flow handling added in #497, especially how loop exits collect state at break and yield. Trace the nested-break example through the verifier and identify where each exit context should join the case end states. Done means the example compiles without a state refinement error and the reported true path is preserved correctly.

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

説明

bug

Follow-up to #494 / #497. With switch cases modelled, a break nested inside a case (for example inside an if) is not followed: the state at that break is dropped, so after the switch the verifier knows nothing about that path. Correct code is rejected, and the message shows a bare true.

@StateSet({"closed", "open"})
class Door {
    @StateRefinement(to = "closed(this)") Door() {}
    @StateRefinement(from = "closed(this)", to = "open(this)") void open() {}
    @StateRefinement(from = "open(this)", to = "closed(this)") void close() {}
}

class NestedBreak {
    // Every path opens the door before leaving the switch, so close() is fine
    static void enter(int k, boolean fast) {
        Door d = new Door();
        switch (k) {
            case 1:
                if (fast) {
                    d.open();
                    break;
                }
                d.open();
                break;
            default:
                d.open();
        }
        d.close();
    }
}

On the #497 branch (432a508c):

State Refinement Error: found k == 1 ? true : open(d) but expected open(d)
31 |         d.close();
Hints:
  - d can be in closed or open here, depending on the path taken, and no sequence of calls moves all of them to open. Make d reach this line in the same state on every path

Expected: no error. The true means "forgotten", which users are not told, and the hint describes a split that does not exist.

Fix direction: record the context at each nested break / yield and join it with the cases' end states, as loops already do for their exits.

Not needed for the error-message study (no study exercise has this shape after a switch).

主要言語
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 を短くまとめたダイジェスト。