Avoid double rounding decimal literals when materializing f32 values
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
Read the literal path through front/lexer/src/scan.rs:470, front/parser/src/expr/primary.rs:349, and front/hir/src/numeric_checks.rs:57 to see where decimal source information is lost before f32 materialization. Discuss the design with @LunaStev before implementation. Reproduce the given program at O0 and O2, then use exact-oracle tests for midpoints, adjacent decimals, negative values, and finite range boundaries; done means the reproduction yields 0x3f800001 while casts, spans, and diagnostics retain their stated semantics.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Decimal floating literals are first converted to f64 in the lexer, then narrowed when Typed HIR selects f32. Near an f32 halfway point, rounding to f64 first can erase which side of the midpoint the original decimal occupied, producing the wrong nearest f32 value.
Starting points: front/lexer/src/scan.rs:470, front/parser/src/expr/primary.rs:349, and front/hir/src/numeric_checks.rs:57. This differs from #927's accepted f32 default and normal finite rounding: the example is rounded to the wrong f32 neighbor even with an explicit f32 declaration.
Reproduction
Audited canonical master d59bdab376bdc04edacdc8029b256cb8d55b5adf on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, Rust 1.89.0 and LLVM 21.1.8.
import("std::math::float")::{float_to_bits_f32};
fun main() {
var value: f32 = 1.0000000596046448;
println("{}", float_to_bits_f32(value));
}
At both O0 and O2 the native program prints 1065353216 (0x3f800000, exactly 1.0).
The exact midpoint between 1.0 and its next f32 neighbor is 1 + 2^-24 = 1.000000059604644775390625. The source decimal 1.0000000596046448 is strictly greater than that midpoint, so its nearest f32 is the next neighbor: bits 1065353217 / 0x3f800001.
The midpoint comparison was checked using Python Decimal with precision 80; it does not use another f64 conversion as the oracle.
Scope
Preserve sufficient source information until the selected floating materialization width is known, and round the literal to that width correctly. Keep f32 as the untyped default, contextual f64 behavior, explicit conversion order, signed zero, underflow and overflow diagnostics. Do not reinterpret this as a request to reject all inexact decimals.
Please mention @LunaStev to discuss the design before starting implementation.
This touches the frontend literal representation shared by both backends, so it is not labeled a good first issue.
Completion criteria
- The reproduction yields
0x3f800001at O0/O2. - Test exact midpoints, decimal values immediately on either side, negative values and finite range boundaries with an exact oracle.
- Preserve source spans and explicit f64-to-f32 cast semantics; distinguish directly materialized f32 literals from intentionally rounded cast chains.
- Ngôn ngữ chính
- Rust
- Star
- 56
- Fork
- 21
- Merge trung bình
- 23 giờ 20 phút
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của wavefnd/Wave
-
Reject unrepresentable POSIX listener descriptors before Unix-domain acceptCó thể đã có người làm @ShahadatTest đã nhận 6 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
wavefnd/Wave#1082 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Preserve expression assembly result types when recording HIR conversionsCó thể đã có người làm @hiyouwhatsapp đã nhận 2 ngày trước. Đang mởbug help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 53/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Preserve the previous build output when writing its Cargo receipt failsCó thể đã có người làm @hiyouwhatsapp đã nhận 2 ngày trước. Đang mởbug build help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Reconcile obsolete staging assets before verifying a new Nightly generationCó thể đã có người làm @hiyouwhatsapp đã nhận 2 ngày trước. Đang mởbug ci help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
servo/rust-smallvec#873 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Panic on live viewport resize when unstyled elements exist in display: none subtreeCó thể đã có người làm @GoCoder7 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DioxusLabs/blitz#1488 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🏷️ good first issue enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
S-Needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày