Sema: fix type in a @floatToInt safety check

Unblocks #15981
This commit is contained in:
Jacob Young 2023-06-18 23:42:30 -04:00 committed by Andrew Kelley
parent 7d6fcf0831
commit 8bd07fb1be

View File

@ -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));