liquid-java / liquid-java/liquidjava

Ghost variables are not correctly initialized in interfaces

Abierto
#44 1 comentario 0 reacciones 1 asignado Ver en GitHub

@pcanelas ya está trabajando en esto.

Desde el 4/7/2025.

bug enhancement
Lenguaje dominante
Java
Estrellas
67
Forks
36
Merge medio
10 d 18 h
PR fusionados (30 d)
3

Descripción

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

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

@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);
}
```
```java
public static void main(String[] args) {
List 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.