| ... | ... | @@ -6030,8 +6030,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6030 | 6030 | if (arg0_value == irb->codegen->invalid_instruction) |
| 6031 | 6031 | return arg0_value; |
| 6032 | 6032 | |
| 6033 | | IrInstruction *actual_tag = ir_build_union_tag(irb, scope, node, arg0_value); |
| 6034 | | IrInstruction *tag_name = ir_build_tag_name(irb, scope, node, actual_tag); |
| 6033 | IrInstruction *tag_name = ir_build_tag_name(irb, scope, node, arg0_value); |
| 6035 | 6034 | return ir_lval_wrap(irb, scope, tag_name, lval, result_loc); |
| 6036 | 6035 | } |
| 6037 | 6036 | case BuiltinFnIdTagType: |
| ... | ... | @@ -21389,10 +21388,6 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 21389 | 21388 | if (type_is_invalid(value->value->type)) |
| 21390 | 21389 | return ira->codegen->invalid_instruction; |
| 21391 | 21390 | |
| 21392 | | if (value->value->type->id == ZigTypeIdEnum) { |
| 21393 | | return value; |
| 21394 | | } |
| 21395 | | |
| 21396 | 21391 | if (value->value->type->id != ZigTypeIdUnion) { |
| 21397 | 21392 | ir_add_error(ira, value, |
| 21398 | 21393 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); |
| ... | ... | @@ -21460,12 +21455,6 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21460 | 21455 | if (type_is_invalid(case_value->value->type)) |
| 21461 | 21456 | return ir_unreach_error(ira); |
| 21462 | 21457 | |
| 21463 | | if (case_value->value->type->id == ZigTypeIdEnum) { |
| 21464 | | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); |
| 21465 | | if (type_is_invalid(case_value->value->type)) |
| 21466 | | return ir_unreach_error(ira); |
| 21467 | | } |
| 21468 | | |
| 21469 | 21458 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); |
| 21470 | 21459 | if (type_is_invalid(casted_case_value->value->type)) |
| 21471 | 21460 | return ir_unreach_error(ira); |
| ... | ... | @@ -21510,12 +21499,6 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21510 | 21499 | if (type_is_invalid(new_value->value->type)) |
| 21511 | 21500 | continue; |
| 21512 | 21501 | |
| 21513 | | if (new_value->value->type->id == ZigTypeIdEnum) { |
| 21514 | | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); |
| 21515 | | if (type_is_invalid(new_value->value->type)) |
| 21516 | | continue; |
| 21517 | | } |
| 21518 | | |
| 21519 | 21502 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); |
| 21520 | 21503 | if (type_is_invalid(casted_new_value->value->type)) |
| 21521 | 21504 | continue; |
| ... | ... | @@ -22352,6 +22335,20 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 22352 | 22335 | if (type_is_invalid(target->value->type)) |
| 22353 | 22336 | return ira->codegen->invalid_instruction; |
| 22354 | 22337 | |
| 22338 | if (target->value->type->id == ZigTypeIdEnumLiteral) { |
| 22339 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 22340 | Buf *field_name = target->value->data.x_enum_literal; |
| 22341 | ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; |
| 22342 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); |
| 22343 | return result; |
| 22344 | } |
| 22345 | |
| 22346 | if (target->value->type->id == ZigTypeIdUnion) { |
| 22347 | target = ir_analyze_union_tag(ira, &instruction->base, target); |
| 22348 | if (type_is_invalid(target->value->type)) |
| 22349 | return ira->codegen->invalid_instruction; |
| 22350 | } |
| 22351 | |
| 22355 | 22352 | assert(target->value->type->id == ZigTypeIdEnum); |
| 22356 | 22353 | |
| 22357 | 22354 | if (instr_is_comptime(target)) { |