liquid-java / liquid-java/liquidjava

Ghost variables are not correctly initialized in interfaces

Ouverte
#44 1 commentaire 0 réactions 1 personne assignée Voir sur GitHub

@pcanelas y travaille déjà.

Depuis le 4/7/2025.

bug enhancement
Langage dominant
Java
Étoiles
67
Forks
36
Merge moyen
10 j 18 h
PR mergées (30 j)
3

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.