[BUG] `DType::from` rejects `S16`, `U16` and `F16`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia con la conversione di DType in src/core/util.rs:76-81 e confronta il suo intervallo accettato con l’enum in src/core/defines.rs:112-139. Segui Array::get_type() in array.rs:427-432 e verifica che S16, U16 e F16 non causino più un panic, anche durante il formatting Debug di un array; i valori non riconosciuti devono produrre un errore chiaro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 827
- Fork
- 59
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di arrayfire/arrayfire-rust
-
Bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
arrayfire/arrayfire-rust#388 ·
-
Bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
arrayfire/arrayfire-rust#387 ·
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
arrayfire/arrayfire-rust#384 ·
-
Bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
arrayfire/arrayfire-rust#385 · 1 commento ·
-
Bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
arrayfire/arrayfire-rust#382 ·
Tutte le issue di arrayfire/arrayfire-rust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
Axis areas are always keyboard-focusable (Sense::drag), even with allow_axis_zoom_drag(false) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug team:backend track:services-maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cowprotocol/services#4950 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
gitbutlerapp/gitbutler#15998 · 1 commento ·