Avoid double rounding decimal literals when materializing f32 values
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 20/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 56
- Forks
- 21
- Merge medio
- 23 h 20 min
- PR fusionados (30 d)
- 45
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de wavefnd/Wave
-
Reject unrepresentable POSIX listener descriptors before Unix-domain acceptPosiblemente ocupada @ShahadatTest la tomó hace 6 días. Abiertobug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
wavefnd/Wave#1082 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Preserve expression assembly result types when recording HIR conversionsPosiblemente ocupada @hiyouwhatsapp la tomó hace 2 días. Abiertobug help wanted
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
bug help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 53/100
Los mantenedores suelen responder en 1 día
-
Preserve the previous build output when writing its Cargo receipt failsPosiblemente ocupada @hiyouwhatsapp la tomó hace 2 días. Abiertobug build help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
Reconcile obsolete staging assets before verifying a new Nightly generationPosiblemente ocupada @hiyouwhatsapp la tomó hace 2 días. Abiertobug ci help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de wavefnd/Wave
Issues similares
-
Panic on live viewport resize when unstyled elements exist in display: none subtreePosiblemente ocupada @GoCoder7 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DioxusLabs/blitz#1488 ·
Los mantenedores suelen responder en 1 día
-
🏷️ good first issue enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
S-Needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
vectordotdev/vrl#2042 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día