| ... | @@ -22626,20 +22626,18 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData | ... | @@ -22626,20 +22626,18 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 22626 | const base_operand_ty = sema.typeOf(operand); | 22626 | const base_operand_ty = sema.typeOf(operand); |
| 22627 | const dest_tag = base_dest_ty.zigTypeTag(mod); | 22627 | const dest_tag = base_dest_ty.zigTypeTag(mod); |
| 22628 | const operand_tag = base_operand_ty.zigTypeTag(mod); | 22628 | const operand_tag = base_operand_ty.zigTypeTag(mod); |
| 22629 | if (dest_tag != operand_tag) { | 22629 | |
| 22630 | return sema.fail(block, src, "expected source and destination types to match, found '{s}' and '{s}'", .{ | 22630 | if (dest_tag != .ErrorSet and dest_tag != .ErrorUnion) { |
| 22631 | @tagName(operand_tag), @tagName(dest_tag), | | |
| 22632 | }); | | |
| 22633 | } else if (dest_tag != .ErrorSet and dest_tag != .ErrorUnion) { | | |
| 22634 | return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(dest_tag)}); | 22631 | return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(dest_tag)}); |
| 22635 | } | 22632 | } |
| 22636 | const dest_ty, const operand_ty = if (dest_tag == .ErrorUnion) .{ | 22633 | if (operand_tag != .ErrorSet and operand_tag != .ErrorUnion) { |
| 22637 | base_dest_ty.errorUnionSet(mod), | 22634 | return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(operand_tag)}); |
| 22638 | base_operand_ty.errorUnionSet(mod), | 22635 | } |
| 22639 | } else .{ | 22636 | if (dest_tag == .ErrorSet and operand_tag == .ErrorUnion) { |
| 22640 | base_dest_ty, | 22637 | return sema.fail(block, src, "cannot cast an error union type to error set", .{}); |
| 22641 | base_operand_ty, | 22638 | } |
| 22642 | }; | 22639 | const dest_ty = if (dest_tag == .ErrorUnion) base_dest_ty.errorUnionSet(mod) else base_dest_ty; |
| | 22640 | const operand_ty = if (operand_tag == .ErrorUnion) base_operand_ty.errorUnionSet(mod) else base_operand_ty; |
| 22643 | | 22641 | |
| 22644 | // operand must be defined since it can be an invalid error value | 22642 | // operand must be defined since it can be an invalid error value |
| 22645 | const maybe_operand_val = try sema.resolveDefinedValue(block, operand_src, operand); | 22643 | const maybe_operand_val = try sema.resolveDefinedValue(block, operand_src, operand); |
| ... | @@ -22681,7 +22679,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData | ... | @@ -22681,7 +22679,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 22681 | if (!dest_ty.isAnyError(mod)) check: { | 22679 | if (!dest_ty.isAnyError(mod)) check: { |
| 22682 | const operand_val = mod.intern_pool.indexToKey(val.toIntern()); | 22680 | const operand_val = mod.intern_pool.indexToKey(val.toIntern()); |
| 22683 | var error_name: InternPool.NullTerminatedString = undefined; | 22681 | var error_name: InternPool.NullTerminatedString = undefined; |
| 22684 | if (dest_tag == .ErrorUnion) { | 22682 | if (operand_tag == .ErrorUnion) { |
| 22685 | if (operand_val.error_union.val != .err_name) break :check; | 22683 | if (operand_val.error_union.val != .err_name) break :check; |
| 22686 | error_name = operand_val.error_union.val.err_name; | 22684 | error_name = operand_val.error_union.val.err_name; |
| 22687 | } else { | 22685 | } else { |