Lower boolean-to-float conversions without invalid Whale casts

Abierto
#909 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@SUJALSPATEL ya está trabajando en esto.

Desde el 9/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug good first issue help wanted needs testing

Problem

Casting a bool to f32/f64 emits IToF_U directly from Whale Type::Bool. Upstream rejects that cast, so valid Wave code fails with an internal compiler error and no source span. LLVM accepts it; bool-to-integer conversions already work in Whale.

Reproduction

Audited on Linux amd64 at 53bb5809cf32d29f5a5a9d313ffa332ea3cd4beb, whose tracked tree matches canonical master c5ab63f9eec388c75b00f5cd59eae28a45a9b39f. Compiler built with Rust 1.89.0, LLVM 21, and the checkout std; Whale is locked to 020d2a4. Executed both CLI paths:

fun main() {
    var flag: bool = true;
    var value: f64 = flag as f64;
}
wavec check bool_float.wave
wavec --whale check bool_float.wave --error-format=json

LLVM exits 0. Whale exits 1 with E4001: internal compiler error in Whale lowering: Whale IR verification failed: InvalidCast { ... op: IToF_U, source: Bool, destination: F64 } and line/column 0. Reproduced with f32 as well; i8/u8/i64/u128 destinations passed.

Scope

Start at whale/src/codegen/expression.rs convert for ConversionKind::UnsignedToFloat. Follow HIR's existing bool-to-float decision and preserve false=0.0/true=1.0; use a valid upstream instruction sequence rather than weakening verification or changing frontend semantics. Starting regressions: tests/whale_backend.rs. Difficulty: easy.

Completion criteria

  • Explicit and accepted implicit bool-to-f32/f64 conversions produce verified IR.
  • Cover true/false, variable/function operands, ordered surrounding casts, and single evaluation.
  • Existing integer/float conversion guards and LLVM behavior remain intact.
Lenguaje dominante
Rust
Estrellas
56
Forks
21
Merge medio
23 h 20 min
PR fusionados (30 d)
45

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wavefnd/Wave

Todos los issues de wavefnd/Wave

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.