mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Sema: fix vector comparison and interning of -0
This commit is contained in:
parent
66ae42bb72
commit
a803e9cf48
@ -2158,6 +2158,9 @@ pub const Const = struct {
|
||||
pub fn to(self: Const, comptime T: type) ConvertError!T {
|
||||
switch (@typeInfo(T)) {
|
||||
.Int => |info| {
|
||||
// Make sure -0 is handled correctly.
|
||||
if (self.eqZero()) return 0;
|
||||
|
||||
const UT = std.meta.Int(.unsigned, info.bits);
|
||||
|
||||
if (!self.fitsInTwosComp(info.signedness, info.bits)) {
|
||||
|
||||
@ -34538,10 +34538,13 @@ fn compareScalar(
|
||||
rhs: Value,
|
||||
ty: Type,
|
||||
) CompileError!bool {
|
||||
const mod = sema.mod;
|
||||
const coerced_lhs = try mod.getCoerced(lhs, ty);
|
||||
const coerced_rhs = try mod.getCoerced(rhs, ty);
|
||||
switch (op) {
|
||||
.eq => return sema.valuesEqual(lhs, rhs, ty),
|
||||
.neq => return !(try sema.valuesEqual(lhs, rhs, ty)),
|
||||
else => return Value.compareHeteroAdvanced(lhs, op, rhs, sema.mod, sema),
|
||||
.eq => return sema.valuesEqual(coerced_lhs, coerced_rhs, ty),
|
||||
.neq => return !(try sema.valuesEqual(coerced_lhs, coerced_rhs, ty)),
|
||||
else => return Value.compareHeteroAdvanced(coerced_lhs, op, coerced_rhs, mod, sema),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user