Internal error "Expr cannot be cast to BoolExpr" on a local assigned from an array element (`Res r = rs[0]`)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- backend, testing-qa
調査の方向性
Start in RefinementTypeChecker.visitCtArrayRead at RefinementTypeChecker.java:273, where the issue says the array element refinement is set. Reproduce with the smaller int[] example and check the SMT failure; compare the generated refinement with the expected equality form. Done when checks on locals assigned from array elements report the expected refinement or state error instead of a ClassCastException.
索引モデルが issue の本文から書いたものです。
説明
Impact: internal error on any check that involves a local holding an array element. A check that should pass fails (false error), and a real violation there is shown as an internal error instead of a refinement or state error.
Description
RefinementTypeChecker.visitCtArrayRead (RefinementTypeChecker.java:273) sets the element's refinement to the bare variable arrayAccess_N instead of _ == arrayAccess_N. Passing xs[0] directly to a call works, but after int c = xs[0] (or Res r = rs[0], var c = objs[0]), c's refinement is that non-boolean term, and the first SMT check that includes it fails with a Z3 ClassCastException: IntExpr for an int[], Expr for an object array. Setting the metadata to _ == arrayAccess_N would probably fix it.
Minimal reproducer (typestate)
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@StateSet({"open", "closed"})
class Res {
@StateRefinement(to = "open(this)")
public Res() {}
@StateRefinement(from = "open(this)")
public void read() {}
@StateRefinement(from = "open(this)", to = "closed(this)")
public void close() {}
}
public class Repro {
void f(Res[] rs) {
Res r = rs[0];
r.close();
r.read();
}
}
Expected
A State Refinement Error at r.close(), as when r is a parameter (control below).
Actual
Error: class com.microsoft.z3.Expr cannot be cast to class com.microsoft.z3.BoolExpr (com.microsoft.z3.Expr and com.microsoft.z3.BoolExpr are in unnamed module of loader 'app')
17 | void f(Res[] rs) {
18 | Res r = rs[0];
19 | r.close();
| ^^^^^^^^^^
20 | r.read();
21 | }
Control: the same calls on a parameter Res r
State Refinement Error: found true but expected open(r⁹)
Smaller form, without typestate
import liquidjava.specification.Refinement;
public class Repro {
static void positive(@Refinement("_ > 0") int x) {}
void f(int[] xs) {
int c = xs[0];
positive(c);
}
}
Error: class com.microsoft.z3.IntExpr cannot be cast to class com.microsoft.z3.BoolExpr (com.microsoft.z3.IntExpr and com.microsoft.z3.BoolExpr are in unnamed module of loader 'app')
6 | void f(int[] xs) {
7 | int c = xs[0];
8 | positive(c);
| ^^^^^^^^^^^^
The reviewers' forms Res r = s.get()[0] (Supplier<Res[]>), Res r = rs[s.getAsInt()], and var c = objs[0]; any(c) (Object[]) give the same error.
Reproduced on main at 1a506fea (liquidjava-verifier 0.0.36).
Context
Found while reviewing #432. Related: #425 (crash on an array read whose element type cannot be resolved).
🤖 Generated with Claude Code
- 主要言語
- Java
- スター
- 73
- フォーク
- 38
- 平均マージ
- 12時間 32分
- マージ済み PR(30日)
- 45
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
liquid-java/liquidjava のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
liquid-java/liquidjava#562 ·
メンテナーはふだん 1 日以内に返信
-
A float ghost crashes the verifier: "Ghost not implemented for type float"対応中かも @MohammedZaid1740 が 7 日前に担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
liquid-java/liquidjava#443 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug real-world-finding
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
liquid-java/liquidjava#395 ·
メンテナーはふだん 1 日以内に返信
-
A ternary between arrays crashes: Sorts (Array Int Int) and Bool are incompatible対応中かも @CatarinaGamboa が 4 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
liquid-java/liquidjava#558 ·
メンテナーはふだん 1 日以内に返信
-
new T[a][b] gets length b instead of a (unsound)対応中かも @CatarinaGamboa が 4 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
liquid-java/liquidjava#557 ·
メンテナーはふだん 1 日以内に返信
liquid-java/liquidjava の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
quelea-projection/Quelea#749 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
erkamyaman/rust-anything#963 ·
メンテナーはふだん 1 日以内に返信
-
api-diagnostics bug jdbc
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
ClickHouse/clickhouse-java#3464 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 76/100
-
Deferred
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Sanne/incus-spawn#2768 ·
メンテナーはふだん 1 日以内に返信