@@ -11202,18 +11202,17 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
11202
11202
const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(block, lhs_src, casted_lhs);
11203
11203
const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(block, rhs_src, casted_rhs);
11204
11204
11205
- if ((lhs_ty.tag () == .comptime_float and rhs_ty.tag () == .comptime_int ) or
11206
- (lhs_ty.tag () == .comptime_int and rhs_ty.tag () == .comptime_float ))
11205
+ if ((lhs_ty.zigTypeTag () == .ComptimeFloat and rhs_ty.zigTypeTag () == .ComptimeInt ) or
11206
+ (lhs_ty.zigTypeTag () == .ComptimeInt and rhs_ty.zigTypeTag () == .ComptimeFloat ))
11207
11207
{
11208
11208
// If it makes a difference whether we coerce to ints or floats before doing the division, error.
11209
11209
// If lhs % rhs is 0, it doesn't matter.
11210
- var lhs_val = maybe_lhs_val orelse unreachable;
11211
- var rhs_val = maybe_rhs_val orelse unreachable;
11212
- var rem = lhs_val.floatRem(rhs_val, resolved_type, sema.arena, target) catch unreachable;
11213
- var float_rem = rem.toFloat(f32);
11214
- if (float_rem != 0.0) {
11215
- return sema.fail(block, src, "ambiguous coercion of division operands: '{s}' and '{s}': division has non-zero reminder: {d}", .{
11216
- @tagName(lhs_ty.tag()), @tagName(rhs_ty.tag()), float_rem,
11210
+ const lhs_val = maybe_lhs_val orelse unreachable;
11211
+ const rhs_val = maybe_rhs_val orelse unreachable;
11212
+ const rem = lhs_val.floatRem(rhs_val, resolved_type, sema.arena, target) catch unreachable;
11213
+ if (rem.compareWithZero(.neq)) {
11214
+ return sema.fail(block, src, "ambiguous coercion of division operands '{s}' and '{s}'; division has non-zero reminder '{}'", .{
11215
+ @tagName(lhs_ty.tag()), @tagName(rhs_ty.tag()), rem.fmtValue(resolved_type, sema.mod),
11217
11216
});
11218
11217
}
11219
11218
}
0 commit comments