| ... | @@ -22354,6 +22354,15 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -22354,6 +22354,15 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 22354 | | 22354 | |
| 22355 | assert(target->value->type->id == ZigTypeIdEnum); | 22355 | assert(target->value->type->id == ZigTypeIdEnum); |
| 22356 | | 22356 | |
| | 22357 | if (target->value->type->data.enumeration.src_field_count == 1 && |
| | 22358 | !target->value->type->data.enumeration.non_exhaustive) { |
| | 22359 | TypeEnumField *only_field = &target->value->type->data.enumeration.fields[0]; |
| | 22360 | ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; |
| | 22361 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| | 22362 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); |
| | 22363 | return result; |
| | 22364 | } |
| | 22365 | |
| 22357 | if (instr_is_comptime(target)) { | 22366 | if (instr_is_comptime(target)) { |
| 22358 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) | 22367 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 22359 | return ira->codegen->invalid_instruction; | 22368 | return ira->codegen->invalid_instruction; |