| ... | @@ -11237,30 +11237,6 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -11237,30 +11237,6 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 11237 | const operand_ty = sema.typeOf(raw_operand_val); | 11237 | const operand_ty = sema.typeOf(raw_operand_val); |
| 11238 | const operand_err_set_ty = operand_ty.errorUnionSet(mod); | 11238 | const operand_err_set_ty = operand_ty.errorUnionSet(mod); |
| 11239 | | 11239 | |
| 11240 | const else_error_ty: ?Type = try validateErrSetSwitch( | | |
| 11241 | sema, | | |
| 11242 | block, | | |
| 11243 | &seen_errors, | | |
| 11244 | &case_vals, | | |
| 11245 | operand_err_set_ty, | | |
| 11246 | inst_data, | | |
| 11247 | scalar_cases_len, | | |
| 11248 | multi_cases_len, | | |
| 11249 | .{ .body = else_case.body, .end = else_case.end, .src = else_prong_src }, | | |
| 11250 | extra.data.bits.has_else, | | |
| 11251 | ); | | |
| 11252 | | | |
| 11253 | var spa: SwitchProngAnalysis = .{ | | |
| 11254 | .sema = sema, | | |
| 11255 | .parent_block = block, | | |
| 11256 | .operand = undefined, // must be set to the unwrapped error code before use | | |
| 11257 | .operand_ptr = .none, | | |
| 11258 | .cond = raw_operand_val, | | |
| 11259 | .else_error_ty = else_error_ty, | | |
| 11260 | .switch_block_inst = inst, | | |
| 11261 | .tag_capture_inst = undefined, | | |
| 11262 | }; | | |
| 11263 | | | |
| 11264 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); | 11240 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| 11265 | try sema.air_instructions.append(gpa, .{ | 11241 | try sema.air_instructions.append(gpa, .{ |
| 11266 | .tag = .block, | 11242 | .tag = .block, |
| ... | @@ -11298,6 +11274,35 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -11298,6 +11274,35 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 11298 | defer child_block.instructions.deinit(gpa); | 11274 | defer child_block.instructions.deinit(gpa); |
| 11299 | defer merges.deinit(gpa); | 11275 | defer merges.deinit(gpa); |
| 11300 | | 11276 | |
| | 11277 | const resolved_err_set = try sema.resolveInferredErrorSetTy(block, src, operand_err_set_ty.toIntern()); |
| | 11278 | if (Type.fromInterned(resolved_err_set).errorSetIsEmpty(mod)) { |
| | 11279 | return sema.resolveBlockBody(block, operand_src, &child_block, non_error_case.body, inst, merges); |
| | 11280 | } |
| | 11281 | |
| | 11282 | const else_error_ty: ?Type = try validateErrSetSwitch( |
| | 11283 | sema, |
| | 11284 | block, |
| | 11285 | &seen_errors, |
| | 11286 | &case_vals, |
| | 11287 | operand_err_set_ty, |
| | 11288 | inst_data, |
| | 11289 | scalar_cases_len, |
| | 11290 | multi_cases_len, |
| | 11291 | .{ .body = else_case.body, .end = else_case.end, .src = else_prong_src }, |
| | 11292 | extra.data.bits.has_else, |
| | 11293 | ); |
| | 11294 | |
| | 11295 | var spa: SwitchProngAnalysis = .{ |
| | 11296 | .sema = sema, |
| | 11297 | .parent_block = block, |
| | 11298 | .operand = undefined, // must be set to the unwrapped error code before use |
| | 11299 | .operand_ptr = .none, |
| | 11300 | .cond = raw_operand_val, |
| | 11301 | .else_error_ty = else_error_ty, |
| | 11302 | .switch_block_inst = inst, |
| | 11303 | .tag_capture_inst = undefined, |
| | 11304 | }; |
| | 11305 | |
| 11301 | if (try sema.resolveDefinedValue(&child_block, src, raw_operand_val)) |operand_val| { | 11306 | if (try sema.resolveDefinedValue(&child_block, src, raw_operand_val)) |operand_val| { |
| 11302 | if (operand_val.errorUnionIsPayload(mod)) { | 11307 | if (operand_val.errorUnionIsPayload(mod)) { |
| 11303 | return sema.resolveBlockBody(block, operand_src, &child_block, non_error_case.body, inst, merges); | 11308 | return sema.resolveBlockBody(block, operand_src, &child_block, non_error_case.body, inst, merges); |