Variable 'this' could not be found when a ghost-refined method is called on another call's result
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 56/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Start by tracing how the verifier handles the get(0) call in Client.java when it follows m.get("k"), then compare that path with the local-variable example in the issue. Use the supplied ArrayListRefinements.java and reproducer to locate the handling of receiver ghost refinements. Done when the chained form reports the expected unknown-size refinement error instead of failing to find this.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A method whose parameter refinement mentions the receiver's ghost (index < size(this)) fails with Not Found Error: Variable 'this' could not be found when it is called on another call's result, as in m.get("k").get(0). With a local variable in between, the verifier reports the expected refinement error (the receiver's size is unknown), so only the chained form breaks.
Minimal reproducer
ArrayListRefinements.java:
import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Ghost;
import liquidjava.specification.Refinement;
import liquidjava.specification.StateRefinement;
@ExternalRefinementsFor("java.util.ArrayList")
@Ghost("int size")
public interface ArrayListRefinements<E> {
@StateRefinement(to = "size(this) == 0")
void ArrayList();
@StateRefinement(to = "size(this) == size(old(this)) + 1")
boolean add(E e);
E get(@Refinement("_ >= 0 && _ < size(this)") int index);
@Refinement("_ == size(this) && _ >= 0")
int size();
}
Client.java:
import java.util.ArrayList;
import java.util.HashMap;
public class Client {
public static void main(String[] args) {
HashMap<String, ArrayList<String>> m = new HashMap<>();
ArrayList<String> l = new ArrayList<>();
l.add("a");
m.put("k", l);
String s = m.get("k").get(0); // Not Found Error: Variable 'this' could not be found
}
}
Expected: a refinement error at get(0) (the list comes from HashMap.get, so its size is unknown), the same one the verifier gives for ArrayList<String> x = m.get("k"); x.get(0);: index == 0 is not a subtype of index >= 0 && index < size(x).
Seen on 1a506fe and main at 19991d3.
Why it matters: real code
Chained reads from a map of lists are common. One of five mined GitHub methods using ArrayList does this: Minimum-Vertex-Cover MVC.readGraph, while (lineNum <= Integer.parseInt(result.get("0").get(0))). The error stops verification of the whole method, and its message points at this, which the user never wrote.
Found while checking mined client code against JDK specs (liquid-java/co-specification, verifier probe V38).
- Ngôn ngữ chính
- Java
- Star
- 73
- Fork
- 38
- Merge trung bình
- 12 giờ 32 phút
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của liquid-java/liquidjava
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
liquid-java/liquidjava#562 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A float ghost crashes the verifier: "Ghost not implemented for type float"Có thể đã có người làm @MohammedZaid1740 đã nhận 7 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
liquid-java/liquidjava#443 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug real-world-finding
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
liquid-java/liquidjava#395 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A ternary between arrays crashes: Sorts (Array Int Int) and Bool are incompatibleCó thể đã có người làm @CatarinaGamboa đã nhận 4 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
liquid-java/liquidjava#558 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
new T[a][b] gets length b instead of a (unsound)Có thể đã có người làm @CatarinaGamboa đã nhận 4 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
liquid-java/liquidjava#557 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của liquid-java/liquidjava
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
quelea-projection/Quelea#749 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
erkamyaman/rust-anything#963 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api-diagnostics bug jdbc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ClickHouse/clickhouse-java#3464 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
-
Deferred
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Sanne/incus-spawn#2768 ·
Maintainer thường phản hồi trong vòng 1 ngày