| ... | ... | @@ -22636,6 +22636,21 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 22636 | 22636 | if (dest_tag == .ErrorSet and operand_tag == .ErrorUnion) { |
| 22637 | 22637 | return sema.fail(block, src, "cannot cast an error union type to error set", .{}); |
| 22638 | 22638 | } |
| 22639 | if (dest_tag == .ErrorUnion and operand_tag == .ErrorUnion and |
| 22640 | base_dest_ty.errorUnionPayload(mod).toIntern() != base_operand_ty.errorUnionPayload(mod).toIntern()) |
| 22641 | { |
| 22642 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22643 | const msg = try sema.errMsg(block, src, "payload types of error unions must match", .{}); |
| 22644 | errdefer msg.destroy(sema.gpa); |
| 22645 | const dest_ty = base_dest_ty.errorUnionPayload(mod); |
| 22646 | const operand_ty = base_operand_ty.errorUnionPayload(mod); |
| 22647 | try sema.errNote(block, src, msg, "destination payload is '{}'", .{dest_ty.fmt(mod)}); |
| 22648 | try sema.errNote(block, src, msg, "operand payload is '{}'", .{operand_ty.fmt(mod)}); |
| 22649 | try addDeclaredHereNote(sema, msg, dest_ty); |
| 22650 | try addDeclaredHereNote(sema, msg, operand_ty); |
| 22651 | break :msg msg; |
| 22652 | }); |
| 22653 | } |
| 22639 | 22654 | const dest_ty = if (dest_tag == .ErrorUnion) base_dest_ty.errorUnionSet(mod) else base_dest_ty; |
| 22640 | 22655 | const operand_ty = if (operand_tag == .ErrorUnion) base_operand_ty.errorUnionSet(mod) else base_operand_ty; |
| 22641 | 22656 | |