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

未关闭
#399 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
40/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java
领域
tooling

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Java
星标
73
派生
38
平均合并
12 小时 32 分钟
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

liquid-java/liquidjava 的其他 Issue

查看 liquid-java/liquidjava 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。