@@ -21126,17 +21126,19 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, IrI
2112621126 ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad);
2112721127 if (!ptr_val)
2112821128 return ira->codegen->invalid_instruction;
21129- ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.source_node);
21130- if (err_union_val == nullptr)
21131- return ira->codegen->invalid_instruction;
21132- if (err_union_val->special != ConstValSpecialRuntime) {
21133- ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set;
21134- assert(err);
21129+ if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
21130+ ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.source_node);
21131+ if (err_union_val == nullptr)
21132+ return ira->codegen->invalid_instruction;
21133+ if (err_union_val->special != ConstValSpecialRuntime) {
21134+ ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set;
21135+ assert(err);
2113521136
21136- IrInstruction *result = ir_const(ira, &instruction->base,
21137- type_entry->data.error_union.err_set_type);
21138- result->value.data.x_err_set = err;
21139- return result;
21137+ IrInstruction *result = ir_const(ira, &instruction->base,
21138+ type_entry->data.error_union.err_set_type);
21139+ result->value.data.x_err_set = err;
21140+ return result;
21141+ }
2114021142 }
2114121143 }
2114221144
@@ -21179,21 +21181,23 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
2117921181 ConstExprValue *ptr_val = ir_resolve_const(ira, value, UndefBad);
2118021182 if (!ptr_val)
2118121183 return ira->codegen->invalid_instruction;
21182- ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.source_node);
21183- if (err_union_val == nullptr)
21184- return ira->codegen->invalid_instruction;
21185- if (err_union_val->special != ConstValSpecialRuntime) {
21186- ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set;
21187- if (err != nullptr) {
21188- ir_add_error(ira, &instruction->base,
21189- buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name)));
21184+ if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
21185+ ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.source_node);
21186+ if (err_union_val == nullptr)
2119021187 return ira->codegen->invalid_instruction;
21191- }
21188+ if (err_union_val->special != ConstValSpecialRuntime) {
21189+ ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set;
21190+ if (err != nullptr) {
21191+ ir_add_error(ira, &instruction->base,
21192+ buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name)));
21193+ return ira->codegen->invalid_instruction;
21194+ }
2119221195
21193- IrInstruction *result = ir_const(ira, &instruction->base, result_type);
21194- result->value.data.x_ptr.special = ConstPtrSpecialRef;
21195- result->value.data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload;
21196- return result;
21196+ IrInstruction *result = ir_const(ira, &instruction->base, result_type);
21197+ result->value.data.x_ptr.special = ConstPtrSpecialRef;
21198+ result->value.data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload;
21199+ return result;
21200+ }
2119721201 }
2119821202 }
2119921203
0 commit comments