Repository navigation
Description
Problem
Valid numeric conditions reach Whale lowering without a HIR conversion to bool. The adapter reports an internal compiler error instead of producing verified IR. Integer operands of &&/|| have the same missing-conversion problem. LLVM accepts these inputs.
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 through both CLI paths:
fun main() -> i32 {
var n: byte = 3;
if (n) { return 0; }
return 1;
}
wavec check condition.wave
wavec --whale check condition.wave --error-format=jsonThe first command exits 0; the second exits 1 with E4001: internal compiler error in Whale lowering: condition missing HIR bool conversion. Also reproduced for i32/u64/f64 conditions and while conditions. Integer n && true fails with logical operand missing HIR bool conversion; floating logical operands are not included because the frontend rejects them.
Scope
Start at front/hir/src/conversions.rs: condition contexts receive no bool demand, and logical operand planning uses plan(..., None, None). whale/src/codegen/mod.rs and whale/src/codegen/walk.rs correctly require bool operands.
Record the existing implicit conversion semantics in HIR: integer nonzero is true; only ±0.0 is false for floating conditions. Do not add backend inference or silently fall back to LLVM. Keep ordered conversions, source spans, and existing rejected operand combinations.
Completion criteria
- Numeric if/else-if/while conditions produce bool conversion facts and verified Whale IR.
- Accepted integer logical operands preserve short-circuiting and single evaluation.
- Cover zero/nonzero, signed values, float signed zeros/NaN/infinities where accepted, and existing bool conditions.
- LLVM behavior and JSON diagnostics remain compatible; malformed HIR remains an internal error.
Activity
Protect compiler inputs and strengthen Whale lowering validation (#911)