False error: the bitwise complement `~x` is rejected as an invalid refinement expression

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

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
40/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

The error comes from the refinement-expression parser in the liquidjava verifier, which receives ~x as raw text. Start with the reproducer's clear method and find where the parser rejects unary operators, then see how #360 (bitwise compound assignments) handles the bitwise family. Done means the reproducer passes verification, or the unsupported ~ is left unconstrained without a syntax error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Impact: correct code is rejected with a syntax error: any use of the bitwise complement operator ~.

Description

~x on an int gives Syntax Error: Invalid refinement expression; the refinement language seems to have no ~, and the expression reaches the parser as text. Until ~ is supported, the result could be left unconstrained (as for other operators the SMT encoding does not cover).

Minimal reproducer

public class Repro {
    static int clear(int flags, int bit) {
        return flags & ~bit;
    }
}

Expected

Correct! Passed Verification.

Actual

Syntax Error: Invalid refinement expression, expected a logical predicate
1 | public class Repro {
2 |     static int clear(int flags, int bit) {
3 |         return flags & ~bit;
  |                        ^^^^
4 |     }
5 | }
Repro.java:3

Reproduced on main at ad055b49 (liquidjava-verifier 0.0.35).

Real-world file that hits it

  • return haystack &= ~needle; — hashsploit/clank (file)

Context

Found while running LiquidJava on the original repository files of 53 real-world typestate and refinement bugs (the files our study exercises were simplified from). The error is reported on code with no refinement of its own, so it is a false error in every file that has the construct. Related: #360 (bitwise compound assignments).

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

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.

Issue khác của liquid-java/liquidjava

Tất cả issue của liquid-java/liquidjava

Issue tương tự

Thêm issue về Java

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.