| ... | ... | @@ -2446,10 +2446,11 @@ static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *s |
| 2446 | 2446 | } |
| 2447 | 2447 | |
| 2448 | 2448 | static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 2449 | | IrInstruction *base_ptr) |
| 2449 | IrInstruction *base_ptr, bool resolve_err_set) |
| 2450 | 2450 | { |
| 2451 | 2451 | IrInstructionTestErrSrc *instruction = ir_build_instruction<IrInstructionTestErrSrc>(irb, scope, source_node); |
| 2452 | 2452 | instruction->base_ptr = base_ptr; |
| 2453 | instruction->resolve_err_set = resolve_err_set; |
| 2453 | 2454 | |
| 2454 | 2455 | ir_ref_instruction(base_ptr, irb->current_basic_block); |
| 2455 | 2456 | |
| ... | ... | @@ -3593,7 +3594,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 3593 | 3594 | |
| 3594 | 3595 | IrInstruction *ret_ptr = ir_build_result_ptr(irb, scope, node, &result_loc_ret->base, |
| 3595 | 3596 | return_value); |
| 3596 | | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, ret_ptr); |
| 3597 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, ret_ptr, false); |
| 3597 | 3598 | |
| 3598 | 3599 | bool should_inline = ir_should_inline(irb->exec, scope); |
| 3599 | 3600 | IrInstruction *is_comptime; |
| ... | ... | @@ -3639,7 +3640,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 3639 | 3640 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 3640 | 3641 | if (err_union_ptr == irb->codegen->invalid_instruction) |
| 3641 | 3642 | return irb->codegen->invalid_instruction; |
| 3642 | | IrInstruction *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr); |
| 3643 | IrInstruction *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr, true); |
| 3643 | 3644 | |
| 3644 | 3645 | IrBasicBlock *return_block = ir_create_basic_block(irb, scope, "ErrRetReturn"); |
| 3645 | 3646 | IrBasicBlock *continue_block = ir_create_basic_block(irb, scope, "ErrRetContinue"); |
| ... | ... | @@ -5987,7 +5988,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 5987 | 5988 | LValPtr, nullptr); |
| 5988 | 5989 | if (err_val_ptr == irb->codegen->invalid_instruction) |
| 5989 | 5990 | return err_val_ptr; |
| 5990 | | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr); |
| 5991 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr, true); |
| 5991 | 5992 | IrBasicBlock *after_cond_block = irb->current_basic_block; |
| 5992 | 5993 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 5993 | 5994 | IrInstruction *cond_br_inst; |
| ... | ... | @@ -6771,7 +6772,7 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 6771 | 6772 | return err_val_ptr; |
| 6772 | 6773 | |
| 6773 | 6774 | IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); |
| 6774 | | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr); |
| 6775 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr, true); |
| 6775 | 6776 | |
| 6776 | 6777 | IrBasicBlock *ok_block = ir_create_basic_block(irb, scope, "TryOk"); |
| 6777 | 6778 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "TryElse"); |
| ... | ... | @@ -7381,7 +7382,7 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 7381 | 7382 | if (err_union_ptr == irb->codegen->invalid_instruction) |
| 7382 | 7383 | return irb->codegen->invalid_instruction; |
| 7383 | 7384 | |
| 7384 | | IrInstruction *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr); |
| 7385 | IrInstruction *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr, true); |
| 7385 | 7386 | |
| 7386 | 7387 | IrInstruction *is_comptime; |
| 7387 | 7388 | if (ir_should_inline(irb->exec, parent_scope)) { |
| ... | ... | @@ -22512,6 +22513,19 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 22512 | 22513 | } |
| 22513 | 22514 | } |
| 22514 | 22515 | |
| 22516 | if (instruction->resolve_err_set) { |
| 22517 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; |
| 22518 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) { |
| 22519 | return ira->codegen->invalid_instruction; |
| 22520 | } |
| 22521 | if (!type_is_global_error_set(err_set_type) && |
| 22522 | err_set_type->data.error_set.err_count == 0) |
| 22523 | { |
| 22524 | assert(err_set_type->data.error_set.infer_fn == nullptr); |
| 22525 | return ir_const_bool(ira, &instruction->base, false); |
| 22526 | } |
| 22527 | } |
| 22528 | |
| 22515 | 22529 | return ir_build_test_err_gen(ira, &instruction->base, value); |
| 22516 | 22530 | } else if (type_entry->id == ZigTypeIdErrorSet) { |
| 22517 | 22531 | return ir_const_bool(ira, &instruction->base, true); |