Lower boolean-to-float conversions without invalid Whale casts

オープン
#909 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@SUJALSPATEL がすでに取り組んでいます。

2026年10月9日 から。

評価

この issue はまだ評価されていません。

説明

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.
主要言語
Rust
スター
56
フォーク
21
平均マージ
23時間 20分
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wavefnd/Wave のほかの issue

wavefnd/Wave の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。