@@ -11202,18 +11202,17 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1120211202 const maybe_lhs_val = try sema.resolveMaybeUndefValIntable(block, lhs_src, casted_lhs);
1120311203 const maybe_rhs_val = try sema.resolveMaybeUndefValIntable(block, rhs_src, casted_rhs);
1120411204
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 ))
1120711207 {
1120811208 // If it makes a difference whether we coerce to ints or floats before doing the division, error.
1120911209 // 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),
1121711216 });
1121811217 }
1121911218 }
0 commit comments