diff --git a/src/Module.zig b/src/Module.zig index add856cfa52f..87cf84d4428d 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2810,10 +2810,6 @@ pub fn coerce(self: *Module, scope: *Scope, dest_type: Type, inst: *Inst) !*Inst } } - // comptime known number to other number - if (try self.coerceNum(scope, dest_type, inst)) |some| - return some; - // error set widening if (inst.ty.zigTypeTag() == .ErrorSet and dest_type.zigTypeTag() == .ErrorSet) { const gotten_err_set = inst.ty.getErrs(); @@ -2877,6 +2873,11 @@ pub fn coerce(self: *Module, scope: *Scope, dest_type: Type, inst: *Inst) !*Inst else => unreachable, } } + + // comptime known number to other number + if (try self.coerceNum(scope, dest_type, inst)) |some| + return some; + // integer widening if (inst.ty.zigTypeTag() == .Int and dest_type.zigTypeTag() == .Int) { assert(inst.value() == null); // handled above diff --git a/src/type.zig b/src/type.zig index 39f8421f3dc9..3bb0a2c64d3b 100644 --- a/src/type.zig +++ b/src/type.zig @@ -229,8 +229,9 @@ pub const Type = extern union { .ErrorSet => { if (a.tag() == .anyerror) { if (b.tag() == .anyerror) - return true; - return false; + return true + else + return false; } if (a.tag() == .error_set_single and b.tag() == .error_set_single) { @@ -260,15 +261,9 @@ pub const Type = extern union { return false; } } - var b_fields_it = b_fields.iterator(); - while (b_fields_it.next()) |entry| { - if (!a_fields.contains(entry.key)) { - return false; - } - } return true; } - return false; + unreachable; }, .ErrorUnion => { const a_casted = a.cast(Payload.ErrorUnion).?; diff --git a/src/value.zig b/src/value.zig index e4f3e29191c8..1c73fe4fe6d2 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1240,7 +1240,7 @@ pub const Value = extern union { const b_name = @fieldParentPtr(Payload.Bytes, "base", b.ptr_otherwise).data; return std.mem.eql(u8, a_name, b_name); } else if (a.tag() == .@"error" and b.tag() == .@"error") { - return std.mem.eql(u8, a.cast(Payload.Error).?.name, b.cast(Payload.Error).?.name); + return a.cast(Payload.Error).?.value == b.cast(Payload.Error).?.value; } } if (a.isType() and b.isType()) { diff --git a/src/zir_sema.zig b/src/zir_sema.zig index 27151610677b..e765e7bd6c53 100644 --- a/src/zir_sema.zig +++ b/src/zir_sema.zig @@ -869,17 +869,16 @@ fn analyzeInstMergeErrorSets(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) .err_single => 1, .multiple => |mul| mul.size, else => unreachable, - })); // TODO should we do this? only true when no overlapping + })); switch (lhs_fields) { .err_single => |name| { - const entry = try mod.getErrorValue(name); - payload.fields.putAssumeCapacity(entry.key, entry.value); + const entry = mod.global_error_set.get(name).?; + payload.fields.putAssumeCapacity(name, entry); }, .multiple => |multiple| { var it = multiple.iterator(); - while (it.next()) |name| { - const entry = try mod.getErrorValue(name.key); + while (it.next()) |entry| { payload.fields.putAssumeCapacity(entry.key, entry.value); } },