liquid-java / liquid-java/liquidjava

Ghost variables are not correctly initialized in interfaces

Đang mở
#44 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@pcanelas đang làm issue này rồi.

Từ ngày 4/7/2025.

bug enhancement
Ngôn ngữ chính
Java
Star
67
Fork
36
Merge trung bình
10 ngày 18 giờ
Pull request đã merge (30 ngày)
3

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.