0xMiden / 0xMiden/miden-vm

Display for a felt-sized push immediate byte-swaps the value

Đang mở
#3,754 4 bình luận 0 reaction 1 người được giao Được @kutluhaneth46 nhận Xem trên GitHub
Ngôn ngữ chính
Rust
Star
772
Fork
352
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
93

Mô tả

`impl fmt::Display for IntValue` (`crates/assembly-syntax/src/parser/value.rs`) renders the `Felt` variant as `write!(f, "{:#08x}", value.as_canonical_u64().to_be())`. The `to_be()` reverses the byte order before formatting, so the printed hex is a different number than the value it came from.

`IntValue::Felt(Felt::new_unchecked(1 << 32)).to_string()` gives `0x1000000` (16777216) rather than `0x100000000` (2^32), and that string parses back to the wrong value. The `U32` arm just above formats without a swap, and `PrettyPrint` renders the canonical value, so the `Felt` arm is the odd one out. `IntValue` and `PushValue` are `pub use`-exported from `pub mod parser`, so any external `to_string()`/`{}` on a felt-range immediate is affected.

The fix is to drop the `to_be()`. I have a patch ready with a regression test (`cargo test -p miden-assembly-syntax` 271 passed, `fmt --check` and `clippy` clean) — could this be assigned to me so I can open the PR per the contribution guidelines?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.