Crash: @Ghost on a nested class gives "Sort mismatch ... supplied sort is Outer$Bag"

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

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

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

評価

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

調査の方向性

Start in TranslatorContextToZ3, focusing on addGhostFunction and getExpr/getSort, where the issue identifies inconsistent names for nested-class sorts. Compare the reproduced nested Outer.Bag case with the stated top-level case, then run the project's verification tests. Done when the nested-class example verifies with the expected success message and existing tests still pass.

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

説明

bug

Impact: any @Ghost declared on a nested class crashes verification of every refinement that uses it; the same class at top level verifies.

Minimal reproducer

import liquidjava.specification.Ghost;
import liquidjava.specification.Refinement;
import liquidjava.specification.StateRefinement;

public class Outer {
    @Ghost("int size")
    static class Bag {
        @StateRefinement(to = "size(this) == 0")
        public Bag() {}

        @StateRefinement(to = "size(this) == size(old(this)) + 1")
        public void add() {}

        @StateRefinement(from = "size(this) > 0")
        public void remove() {}
    }

    static void ok() {
        Bag b = new Bag();
        b.add();
        b.remove();
    }
}

Expected: Correct! Passed Verification., as for the same Bag as a top-level class.

Actual (main @ 0053074e):

Error: Sort mismatch at argument #1 for function (declare-fun Outer$Bag.size (Outer.Bag) Int) supplied sort is Outer$Bag
 9 |         public Bag() {}
10 | 
11 |         @StateRefinement(to = "size(this) == size(old(this)) + 1")
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 |         public void add() {}
13 | 

Error: Sort mismatch at argument #1 for function (declare-fun Outer$Bag.size (Outer.Bag) Int) supplied sort is Outer$Bag
12 |         public void add() {}
13 | 
14 |         @StateRefinement(from = "size(this) > 0")
   |                                  ^^^^^^^^^^^^^^
15 |         public void remove() {}
16 |     }

Cause. The two sides name the class's Z3 sort differently. TranslatorContextToZ3.addGhostFunction builds the ghost's domain from CtTypeReference.toString() (Outer.Bag), while TranslatorContextToZ3.getExpr builds the sort of this from getQualifiedName() (Outer$Bag). For a top-level class both are the same string. Using one naming for both (e.g. getQualifiedName() in addGhostFunction and getSort) should fix it.

🤖 Generated with Claude Code

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