Commit 8bd07fb1be

Jacob Young <jacobly0@users.noreply.github.com>
2023-06-19 05:42:30
Sema: fix type in a `@floatToInt` safety check
Unblocks #15981
1 parent 7d6fcf0
Changed files (1)
src/Sema.zig
@@ -20771,7 +20771,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
     try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
     if (dest_ty.intInfo(mod).bits == 0) {
         if (block.wantSafety()) {
-            const ok = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_eq_optimized else .cmp_eq, operand, try sema.addConstant(operand_ty, try mod.intValue(operand_ty, 0)));
+            const ok = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_eq_optimized else .cmp_eq, operand, try sema.addConstant(operand_ty, try mod.floatValue(operand_ty, 0.0)));
             try sema.addSafetyCheck(block, ok, .integer_part_out_of_bounds);
         }
         return sema.addConstant(dest_ty, try mod.intValue(dest_ty, 0));