Soundness: a field write through another object of the same class (`o.x = 5`) is applied to `this.x`

未關閉
#438 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
66/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
testing-qa

研究方向

Start with RefinementTypeChecker.visitAssignment at RefinementTypeChecker.java:255-258 and compare its field write handling with visitCtFieldRead and Utils.accessesTrackedField, which the issue says handles reads. Use the minimal Repro example to check the current result and the control without the write. Done when the same-class write no longer makes verification incorrectly pass and the expected refinement error is reported.

由索引模型根據 Issue 內容生成。

描述

bug

Impact: a real violation passes verification (missed error).

Description

A field write through another object of the same class (o.x = 5) is recorded as a write to this.x. RefinementTypeChecker.visitAssignment (RefinementTypeChecker.java:255-258) names every CtFieldWrite with Utils.qualifyFieldName, whatever its target. #322 fixed this for reads (visitCtFieldRead checks Utils.accessesTrackedField); this is the write side. Writes to a field of another class (a.x = 5 with A a) and reads of o.x are handled correctly. A write whose target is not this could skip the update of this.x, or havoc it since o may be this.

Minimal reproducer

import liquidjava.specification.Refinement;

public class Repro {
    int x;

    void m(Repro o) {
        o.x = 5;
        @Refinement("_ == 5") int k = this.x;   // this.x is unknown
    }
}

Expected

A Refinement Error at k (this.x may be anything).

Actual

Correct! Passed Verification.

Control: without o.x = 5

Refinement Error: k¹ == x is not a subtype of k¹ == 5

Not a duplicate of #340: that one is about a field's initializer being assumed in another method; here the value comes from a write to a different object in the same method.

Reproduced on main at 1a506fea (liquidjava-verifier 0.0.36).

Context

Found while reviewing #432. Related: #322.

🤖 Generated with Claude Code

主要語言
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 摘要。