[BUG] `DType::from` rejects `S16`, `U16` and `F16`
評価
調査の方向性
src/core/util.rs:76-81 の DType 変換から始め、受け付ける範囲を src/core/defines.rs:112-139 の enum と比較してください。array.rs:427-432 の Array::get_type() を追跡し、配列を Debug フォーマットする場合も含めて、S16、U16、F16 で panic が発生しなくなっていることを確認してください。認識されない値では、明確なエラーになるようにしてください。
索引モデルが issue の本文から書いたものです。
説明
impl From<u32> for DType {
fn from(t: u32) -> Self {
assert!(DType::F32 as u32 <= t && t <= DType::U64 as u32);
unsafe { mem::transmute(t) }
}
}
The upper bound is DType::U64, which is 9. But the enum continues past it (src/core/defines.rs:112-139):
U64 = 9,
S16 = 10,
U16 = 11,
F16 = 12,
So the assert fires for three of the crate's own supported types. Array::get_type() (array.rs:427-432) is the caller, which means:
let a = randu::<half::f16>(dim4!(3, 3));
let t = a.get_type(); // panics
println!("{:?}", a); // panics — Debug impl calls get_type()
This is not a version-skew problem — it's wrong against a correct 3.8 library, and has been since f16 support was added. It's also the inverse mistake to the one in AfError::from: that assert is too loose, this one is too tight.
Fix: bound at DType::F16 as u32, or better, use an exhaustive match with a clear error for unrecognised values. Note ArrayFire 3.10 adds s8 = 13, so a match would future-proof this.
Found by Claude Opus 5. Verified manually.
- 主要言語
- Rust
- スター
- 826
- フォーク
- 60
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
arrayfire/arrayfire-rust のほかの issue
-
Bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
arrayfire/arrayfire-rust#388 ·
-
Bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
arrayfire/arrayfire-rust#387 ·
-
[BUG] device_info() buffers are 64 bytes; CUDA backend writes 257, corrupting the stack対応中かも @phil-opp が 120 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
arrayfire/arrayfire-rust#384 ·
-
Bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
arrayfire/arrayfire-rust#385 · コメント 1 件 ·
-
[BUG] opencl-interop `get_device_type` always returns `DeviceType::ALL`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンBug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
arrayfire/arrayfire-rust#382 ·
arrayfire/arrayfire-rust の issue をすべて見る
似ている issue
-
autofix:working
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
libracoder/kiri#1138 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
roc-lang/basic-webserver#277 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
samkerrcode/opengent#113 ·
メンテナーはふだん 1 日以内に返信
-
app bug session
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信