Soundness: a local variable with a constant's name shadows the constant (Format.JPG read as local JPG)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu trong RefinementTypeChecker.visitCtFieldRead, được xác định trong issue, và tái hiện xung đột tên bằng ví dụ Java được cung cấp. Kiểm tra cách tra cứu ngữ cảnh phân biệt một biến cục bộ với trường đang được đọc; issue mô tả một bản sửa tiềm năng và cho biết cả 347 bài kiểm thử đều đạt. Được xem là hoàn tất khi trình tái hiện báo lỗi refinement tại onlyPng(g) và bộ kiểm thử vẫn đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
A field read of a constant such as Format.JPG is resolved to a local variable with the same simple name (JPG), if one is in scope, instead of the constant. The refinement of the local is then used, so real violations are accepted.
Minimal reproducer
import liquidjava.specification.Refinement;
public class Repro {
enum Format { JPG, PNG }
static void onlyPng(@Refinement("_ == Format.PNG") Format f) {}
public static void main(String[] args) {
Format JPG = Format.PNG; // a local that happens to share the constant's name
Format g = Format.JPG; // the enum constant JPG, not the local
onlyPng(g); // expected error: g is JPG
}
}
Expected
A refinement error at onlyPng(g): g holds Format.JPG.
Actual
Correct! Passed Verification.
Removing the line Format JPG = Format.PNG; gives the expected error (g == JPG is not a subtype of g == Format.PNG), so the name clash is what hides it.
Reproduced on main at fbfb4e23.
Where
RefinementTypeChecker.visitCtFieldRead: its first branch looks the field up by simple name in the context (where the local lives) without checking that the variable found is the field being read. A candidate fix (about 5 lines, found during the review of #319) only uses the context variable when it really is that field, and otherwise falls through; it keeps all 347 tests passing.
Context
Found by the adversarial review of #319 (fix for #302): with #319 the same clash inside an if condition (if (f == Format.JPG)) turns a former crash into an accepted violation, so this should be fixed before or with #319.
- Ngôn ngữ chính
- Java
- Star
- 67
- Fork
- 36
- Merge trung bình
- 4 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 7
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ó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
liquid-java/liquidjava#323 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Soundness: a field of another class or object is read as this class's field with the same nameĐang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
liquid-java/liquidjava#322 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
liquid-java/liquidjava#318 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
liquid-java/liquidjava#317 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
liquid-java/liquidjava#316 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của liquid-java/liquidjava
Issue tương tự
-
Update license yearĐang mở0 - Backlog 1 - Ready documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
cbor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
FasterXML/jackson-dataformats-binary#844 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/iceberg#18351 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
repowise-dev/repowise#2945 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Interpolating settings.xml can lead to malformed XML when variable value contains double-hyphenĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/maven#13321 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày