| ... | @@ -16864,26 +16864,27 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa | ... | @@ -16864,26 +16864,27 @@ static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrNa |
| 16864 | if (type_is_invalid(casted_value->value->type)) | 16864 | if (type_is_invalid(casted_value->value->type)) |
| 16865 | return ira->codegen->invalid_inst_gen; | 16865 | return ira->codegen->invalid_inst_gen; |
| 16866 | | 16866 | |
| 16867 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | | |
| 16868 | true, false, PtrLenUnknown, 0, 0, 0, false); | | |
| 16869 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | | |
| 16870 | if (instr_is_comptime(casted_value)) { | 16867 | if (instr_is_comptime(casted_value)) { |
| 16871 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 16868 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 16872 | if (val == nullptr) | 16869 | if (val == nullptr) |
| 16873 | return ira->codegen->invalid_inst_gen; | 16870 | return ira->codegen->invalid_inst_gen; |
| 16874 | ErrorTableEntry *err = casted_value->value->data.x_err_set; | 16871 | ErrorTableEntry *err = casted_value->value->data.x_err_set; |
| 16875 | if (!err->cached_error_name_val) { | 16872 | if (!err->cached_error_name_val) { |
| 16876 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 16873 | err->cached_error_name_val = create_sentineled_str_lit( |
| 16877 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 16874 | ira->codegen, &err->name, |
| | 16875 | ira->codegen->intern.for_zero_byte()); |
| 16878 | } | 16876 | } |
| 16879 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); | 16877 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16880 | copy_const_val(ira->codegen, result->value, err->cached_error_name_val); | 16878 | result->value = err->cached_error_name_val; |
| 16881 | result->value->type = str_type; | | |
| 16882 | return result; | 16879 | return result; |
| 16883 | } | 16880 | } |
| 16884 | | 16881 | |
| 16885 | ira->codegen->generate_error_name_table = true; | 16882 | ira->codegen->generate_error_name_table = true; |
| 16886 | | 16883 | |
| | 16884 | ZigType *u8_ptr_type = get_pointer_to_type_extra2(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| | 16885 | true, false, PtrLenUnknown, 0, 0, 0, false, |
| | 16886 | VECTOR_INDEX_NONE, nullptr, ira->codegen->intern.for_zero_byte()); |
| | 16887 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 16887 | return ir_build_err_name_gen(ira, &instruction->base.base, value, str_type); | 16888 | return ir_build_err_name_gen(ira, &instruction->base.base, value, str_type); |
| 16888 | } | 16889 | } |
| 16889 | | 16890 | |