mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
stage2: various small type fixes
This commit is contained in:
parent
fb3c5b84ed
commit
9a59cdcd41
@ -2801,6 +2801,12 @@ pub fn resolvePeerTypes(self: *Module, scope: *Scope, instructions: []*Inst) !Ty
|
||||
prev_inst = next_inst;
|
||||
continue;
|
||||
}
|
||||
if (next_inst.ty.zigTypeTag() == .Undefined)
|
||||
continue;
|
||||
if (prev_inst.ty.zigTypeTag() == .Undefined) {
|
||||
prev_inst = next_inst;
|
||||
continue;
|
||||
}
|
||||
if (prev_inst.ty.isInt() and
|
||||
next_inst.ty.isInt() and
|
||||
prev_inst.ty.isSignedInt() == next_inst.ty.isSignedInt())
|
||||
|
||||
@ -163,7 +163,7 @@ pub const Type = extern union {
|
||||
// Hot path for common case:
|
||||
if (a.castPointer()) |a_payload| {
|
||||
if (b.castPointer()) |b_payload| {
|
||||
return eql(a_payload.pointee_type, b_payload.pointee_type);
|
||||
return a.tag() == b.tag() and eql(a_payload.pointee_type, b_payload.pointee_type);
|
||||
}
|
||||
}
|
||||
const is_slice_a = isSlice(a);
|
||||
@ -189,7 +189,7 @@ pub const Type = extern union {
|
||||
.Array => {
|
||||
if (a.arrayLen() != b.arrayLen())
|
||||
return false;
|
||||
if (a.elemType().eql(b.elemType()))
|
||||
if (!a.elemType().eql(b.elemType()))
|
||||
return false;
|
||||
const sentinel_a = a.arraySentinel();
|
||||
const sentinel_b = b.arraySentinel();
|
||||
@ -501,9 +501,9 @@ pub const Type = extern union {
|
||||
.noreturn,
|
||||
=> return out_stream.writeAll(@tagName(t)),
|
||||
|
||||
.enum_literal => return out_stream.writeAll("@TypeOf(.EnumLiteral)"),
|
||||
.@"null" => return out_stream.writeAll("@TypeOf(null)"),
|
||||
.@"undefined" => return out_stream.writeAll("@TypeOf(undefined)"),
|
||||
.enum_literal => return out_stream.writeAll("@Type(.EnumLiteral)"),
|
||||
.@"null" => return out_stream.writeAll("@Type(.Null)"),
|
||||
.@"undefined" => return out_stream.writeAll("@Type(.Undefined)"),
|
||||
|
||||
.@"anyframe" => return out_stream.writeAll("anyframe"),
|
||||
.anyerror_void_error_union => return out_stream.writeAll("anyerror!void"),
|
||||
|
||||
@ -301,15 +301,15 @@ pub const Value = extern union {
|
||||
.comptime_int_type => return out_stream.writeAll("comptime_int"),
|
||||
.comptime_float_type => return out_stream.writeAll("comptime_float"),
|
||||
.noreturn_type => return out_stream.writeAll("noreturn"),
|
||||
.null_type => return out_stream.writeAll("@TypeOf(null)"),
|
||||
.undefined_type => return out_stream.writeAll("@TypeOf(undefined)"),
|
||||
.null_type => return out_stream.writeAll("@Type(.Null)"),
|
||||
.undefined_type => return out_stream.writeAll("@Type(.Undefined)"),
|
||||
.fn_noreturn_no_args_type => return out_stream.writeAll("fn() noreturn"),
|
||||
.fn_void_no_args_type => return out_stream.writeAll("fn() void"),
|
||||
.fn_naked_noreturn_no_args_type => return out_stream.writeAll("fn() callconv(.Naked) noreturn"),
|
||||
.fn_ccc_void_no_args_type => return out_stream.writeAll("fn() callconv(.C) void"),
|
||||
.single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"),
|
||||
.const_slice_u8_type => return out_stream.writeAll("[]const u8"),
|
||||
.enum_literal_type => return out_stream.writeAll("@TypeOf(.EnumLiteral)"),
|
||||
.enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"),
|
||||
.anyframe_type => return out_stream.writeAll("anyframe"),
|
||||
|
||||
.null_value => return out_stream.writeAll("null"),
|
||||
|
||||
@ -1239,6 +1239,12 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
|
||||
|
||||
if (casted_lhs.value()) |lhs_val| {
|
||||
if (casted_rhs.value()) |rhs_val| {
|
||||
if (lhs_val.isUndef() or rhs_val.isUndef()) {
|
||||
return mod.constInst(scope, inst.base.src, .{
|
||||
.ty = resolved_type,
|
||||
.val = Value.initTag(.undef),
|
||||
});
|
||||
}
|
||||
return analyzeInstComptimeOp(mod, scope, scalar_type, inst, lhs_val, rhs_val);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user