| author | |
| committer | |
| log | a803e9cf48e9566638e6ec1e23fe0b885e2651ee |
| tree | 931d88834f2a1292dffb4a44207b2295d626212b |
| parent | 66ae42bb72a9ad4b1cd44b32fa5be322b07a5ffb |
2 files changed, 9 insertions(+), 3 deletions(-)
lib/std/math/big/int.zig+3| ... | @@ -2158,6 +2158,9 @@ pub const Const = struct { | ... | @@ -2158,6 +2158,9 @@ pub const Const = struct { |
| 2158 | pub fn to(self: Const, comptime T: type) ConvertError!T { | 2158 | pub fn to(self: Const, comptime T: type) ConvertError!T { |
| 2159 | switch (@typeInfo(T)) { | 2159 | switch (@typeInfo(T)) { |
| 2160 | .Int => |info| { | 2160 | .Int => |info| { |
| 2161 | // Make sure -0 is handled correctly. | ||
| 2162 | if (self.eqZero()) return 0; | ||
| 2163 | |||
| 2161 | const UT = std.meta.Int(.unsigned, info.bits); | 2164 | const UT = std.meta.Int(.unsigned, info.bits); |
| 2162 | 2165 | ||
| 2163 | if (!self.fitsInTwosComp(info.signedness, info.bits)) { | 2166 | if (!self.fitsInTwosComp(info.signedness, info.bits)) { |
src/Sema.zig+6-3| ... | @@ -34538,10 +34538,13 @@ fn compareScalar( | ... | @@ -34538,10 +34538,13 @@ fn compareScalar( |
| 34538 | rhs: Value, | 34538 | rhs: Value, |
| 34539 | ty: Type, | 34539 | ty: Type, |
| 34540 | ) CompileError!bool { | 34540 | ) CompileError!bool { |
| 34541 | const mod = sema.mod; | ||
| 34542 | const coerced_lhs = try mod.getCoerced(lhs, ty); | ||
| 34543 | const coerced_rhs = try mod.getCoerced(rhs, ty); | ||
| 34541 | switch (op) { | 34544 | switch (op) { |
| 34542 | .eq => return sema.valuesEqual(lhs, rhs, ty), | 34545 | .eq => return sema.valuesEqual(coerced_lhs, coerced_rhs, ty), |
| 34543 | .neq => return !(try sema.valuesEqual(lhs, rhs, ty)), | 34546 | .neq => return !(try sema.valuesEqual(coerced_lhs, coerced_rhs, ty)), |
| 34544 | else => return Value.compareHeteroAdvanced(lhs, op, rhs, sema.mod, sema), | 34547 | else => return Value.compareHeteroAdvanced(coerced_lhs, op, coerced_rhs, mod, sema), |
| 34545 | } | 34548 | } |
| 34546 | } | 34549 | } |
| 34547 | 34550 |