False error: an escaped char literal ('\r') is rejected as an invalid refinement expression

Đang mở
#398 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
52/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
compilers

Hướng nghiên cứu

Start from the minimal reproducer in the issue: a Repro.java with if (b == '\r') on a byte should verify, but the refinement parser rejects the escaped char literal with "Invalid refinement expression, expected a logical predicate". The payload does not name the parser file, so find where char literals in refinement expressions are read and how their escape sequences are handled. Done means the reproducer and the '\t' variant both print Correct! Passed Verification., with an existing plain 'a' comparison still passing.

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 comparison with an escaped char literal ('\r', '\t').

Description

A plain character literal works (c == 'a' passes), but an escape sequence does not: the literal's text seems to reach the refinement parser unescaped (or with a backslash it cannot read), and the parser reports a syntax error on the user's code.

Minimal reproducer

public class Repro {
    static boolean endOfLine(byte b) {
        if (b == '\r') {
            return true;
        }
        return false;
    }
}

Expected

Correct! Passed Verification.

Actual

Syntax Error: Invalid refinement expression, expected a logical predicate
1 | public class Repro {
2 |     static boolean endOfLine(byte b) {
3 |         if (b == '\r') {
  |                  ^^^^
4 |             return true;
5 |         }
Repro.java:3

The same with return c == '\t'; on a char c. Reproduced on main at ad055b49 (liquidjava-verifier 0.0.35).

Real-world file that hits it

  • if (b == '\r') { — 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.

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.