liquid-java / liquid-java/liquidjava

Ghost variables are not correctly initialized in interfaces

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

@pcanelas がすでに取り組んでいます。

2025年7月4日 から。

bug enhancement
主要言語
Java
スター
67
フォーク
36
平均マージ
10日 18時間
マージ済み PR(30日)
3

説明

Ghost variable initialization is dependent on declaring the constructor for the type the that the refinements are for. This declaration implicitly initializes int variables in a way equivalent to @StateRefinement(to = "var(this) == 0")
It is not possible to declare constructors for interface types as these don't have constructors. This prohibits the correct initialization of both Ghost variables and States for interfaces

@ExternalRefinementsFor("java.util.List")
@Ghost("int size2")
public interface ListRefinements<E> {

	@StateRefinement(to = "size2(this) == (size2(old(this)) + 1)")
	public boolean add(E elem);

	@StateRefinement(from = "size2(this) > 0", to = "size2(this) == (size2(old(this)) - 1)")
	public void remove(@Refinement("index >= 0") int index);
}
	public static void main(String[] args) {
		List<Integer> l = new ArrayList<>();

		l.add(0);

		int a = l.remove(0);
	}

The error provided is Failed to check state transitions when calling l.remove(0)

This error messages is identical to the error message that would appear when attempting the same operation on a concrete class without a declared constructor in the Refinement definitions

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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