| ... | ... | @@ -10970,8 +10970,7 @@ fn analyzeSwitchBlock( |
| 10970 | 10970 | .case_idx = index, |
| 10971 | 10971 | } }), |
| 10972 | 10972 | capture == .by_ref, |
| 10973 | | is_special, |
| 10974 | | if (!is_special) case_vals else undefined, |
| 10973 | if (is_special) .special else .{ .item_refs = &.{.fromValue(item_opv)} }, |
| 10975 | 10974 | if (is_inline) .fromValue(item_opv) else .none, |
| 10976 | 10975 | validated_switch.else_err_ty, |
| 10977 | 10976 | ); |
| ... | ... | @@ -12569,11 +12568,7 @@ fn resolveSwitchProng( |
| 12569 | 12568 | operand_src, |
| 12570 | 12569 | capture_src, |
| 12571 | 12570 | capture == .by_ref, |
| 12572 | | kind == .special, |
| 12573 | | switch (kind) { |
| 12574 | | .item_refs => |item_refs| item_refs, |
| 12575 | | .has_ranges, .special => undefined, |
| 12576 | | }, |
| 12571 | kind, |
| 12577 | 12572 | inline_case_capture, |
| 12578 | 12573 | else_err_ty, |
| 12579 | 12574 | ); |
| ... | ... | @@ -12702,11 +12697,7 @@ fn analyzeSwitchProng( |
| 12702 | 12697 | operand_src, |
| 12703 | 12698 | capture_src, |
| 12704 | 12699 | capture == .by_ref, |
| 12705 | | kind == .special, |
| 12706 | | switch (kind) { |
| 12707 | | .item_refs => |item_refs| item_refs, |
| 12708 | | .has_ranges, .special => undefined, |
| 12709 | | }, |
| 12700 | kind, |
| 12710 | 12701 | inline_case_capture, |
| 12711 | 12702 | else_err_ty, |
| 12712 | 12703 | ); |
| ... | ... | @@ -12783,9 +12774,7 @@ fn analyzeSwitchPayloadCapture( |
| 12783 | 12774 | operand_src: LazySrcLoc, |
| 12784 | 12775 | capture_src: LazySrcLoc, |
| 12785 | 12776 | capture_by_ref: bool, |
| 12786 | | is_special_prong: bool, |
| 12787 | | /// May be `undefined` if `is_special_prong` is `true`. |
| 12788 | | case_vals: []const Air.Inst.Ref, |
| 12777 | kind: SwitchProngKind, |
| 12789 | 12778 | /// If this is not `.none`, this is an inline capture. |
| 12790 | 12779 | inline_case_capture: Air.Inst.Ref, |
| 12791 | 12780 | else_err_ty: ?Type, |
| ... | ... | @@ -12829,7 +12818,7 @@ fn analyzeSwitchPayloadCapture( |
| 12829 | 12818 | |
| 12830 | 12819 | const operand_ptr_ty = if (capture_by_ref) sema.typeOf(operand_ptr) else undefined; |
| 12831 | 12820 | |
| 12832 | | if (is_special_prong) { |
| 12821 | if (kind == .special) { |
| 12833 | 12822 | if (capture_by_ref) return operand_ptr; |
| 12834 | 12823 | return switch (operand_ty.zigTypeTag(zcu)) { |
| 12835 | 12824 | .error_set => e: { |
| ... | ... | @@ -12846,6 +12835,8 @@ fn analyzeSwitchPayloadCapture( |
| 12846 | 12835 | |
| 12847 | 12836 | switch (operand_ty.zigTypeTag(zcu)) { |
| 12848 | 12837 | .@"union" => { |
| 12838 | const case_vals = kind.item_refs; |
| 12839 | |
| 12849 | 12840 | const union_obj = zcu.typeToUnion(operand_ty).?; |
| 12850 | 12841 | const first_item_val = sema.resolveConstDefinedValue(case_block, .unneeded, case_vals[0], undefined) catch unreachable; |
| 12851 | 12842 | |
| ... | ... | @@ -13141,6 +13132,7 @@ fn analyzeSwitchPayloadCapture( |
| 13141 | 13132 | ); |
| 13142 | 13133 | } |
| 13143 | 13134 | |
| 13135 | const case_vals = kind.item_refs; |
| 13144 | 13136 | if (case_vals.len == 1) { |
| 13145 | 13137 | const item_val = sema.resolveConstDefinedValue(case_block, .unneeded, case_vals[0], undefined) catch unreachable; |
| 13146 | 13138 | const item_ty = try pt.singleErrorSetType(item_val.getErrorName(zcu).unwrap().?); |
| ... | ... | @@ -13161,11 +13153,16 @@ fn analyzeSwitchPayloadCapture( |
| 13161 | 13153 | // switch condition. It is comptime-known if there is only one item. |
| 13162 | 13154 | if (capture_by_ref) { |
| 13163 | 13155 | return operand_ptr; |
| 13164 | | } else if (case_vals.len == 1) { |
| 13165 | | return case_vals[0]; |
| 13166 | | } else { |
| 13167 | | return operand_val; |
| 13168 | 13156 | } |
| 13157 | switch (kind) { |
| 13158 | .special => unreachable, |
| 13159 | .item_refs => |case_vals| { |
| 13160 | // If there's only a single item, the capture is comptime-known! |
| 13161 | if (case_vals.len == 1) return case_vals[0]; |
| 13162 | }, |
| 13163 | .has_ranges => {}, |
| 13164 | } |
| 13165 | return operand_val; |
| 13169 | 13166 | }, |
| 13170 | 13167 | } |
| 13171 | 13168 | } |