Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

False error: array length is not known to be non-negative

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

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
半天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java
領域
compilers

研究方向

The bug is in how length(x) is encoded for the SMT solver, which the payload does not locate, so start by finding where array length is translated. Use the reproducer's size method with @Refinement("_ >= 0") as the test case. Done when that snippet prints Correct! Passed Verification. and existing tests still pass.

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

描述

bug

Impact: correct code is rejected (false error).

Description

length(x) is not known to be non-negative, so the solver picks a negative length. Any refinement that needs length(a) >= 0 must be written out by hand.

Minimal reproducer

import liquidjava.specification.Refinement;

class Len {
    @Refinement("_ >= 0")
    static int size(int[] names) {
        return names.length;
    }
}

Expected

Correct! Passed Verification.

Actual (main ad055b49)

Refinement Error: #ret⁰ == length(names) is not a subtype of #ret⁰ >= 0
 --> Counterexample: names == ((as const (Array Int Int)) (- 1)) && #ret⁰ == -1

Possible fix

Assume length(x) >= 0 for every array variable when it enters the context, or add the axiom in the SMT translation of length.

主要語言
Java
星號
67
分支
36
平均合併
2 天 2 小時
30 天內合併 PR
34

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

liquid-java/liquidjava 的其他 Issue

查看 liquid-java/liquidjava 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。