| ... | @@ -7622,6 +7622,10 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -7622,6 +7622,10 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 7622 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 7622 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7623 | const src = inst_data.src(); | 7623 | const src = inst_data.src(); |
| 7624 | const operand = try sema.resolveInst(inst_data.operand); | 7624 | const operand = try sema.resolveInst(inst_data.operand); |
| | 7625 | return sema.analyzeErrUnionCode(block, src, operand); |
| | 7626 | } |
| | 7627 | |
| | 7628 | fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Inst.Ref) CompileError!Air.Inst.Ref { |
| 7625 | const operand_ty = sema.typeOf(operand); | 7629 | const operand_ty = sema.typeOf(operand); |
| 7626 | if (operand_ty.zigTypeTag() != .ErrorUnion) { | 7630 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| 7627 | return sema.fail(block, src, "expected error union type, found '{}'", .{ | 7631 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| ... | @@ -14129,6 +14133,14 @@ fn analyzeCmp( | ... | @@ -14129,6 +14133,14 @@ fn analyzeCmp( |
| 14129 | // numeric types. | 14133 | // numeric types. |
| 14130 | return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src); | 14134 | return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src); |
| 14131 | } | 14135 | } |
| | 14136 | if (is_equality_cmp and lhs_ty.zigTypeTag() == .ErrorUnion and rhs_ty.zigTypeTag() == .ErrorSet) { |
| | 14137 | const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs); |
| | 14138 | return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src); |
| | 14139 | } |
| | 14140 | if (is_equality_cmp and lhs_ty.zigTypeTag() == .ErrorSet and rhs_ty.zigTypeTag() == .ErrorUnion) { |
| | 14141 | const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs); |
| | 14142 | return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src); |
| | 14143 | } |
| 14132 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; | 14144 | const instructions = &[_]Air.Inst.Ref{ lhs, rhs }; |
| 14133 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]LazySrcLoc{ lhs_src, rhs_src } }); | 14145 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]LazySrcLoc{ lhs_src, rhs_src } }); |
| 14134 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { | 14146 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { |