| ... | ... | @@ -14875,19 +14875,19 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 14875 | 14875 | |
| 14876 | 14876 | // cast from inferred struct type to array, union, or struct |
| 14877 | 14877 | if (is_anon_container(actual_type)) { |
| 14878 | | AstNode *decl_node = actual_type->data.structure.decl_node; |
| 14879 | | ir_assert(decl_node->type == NodeTypeContainerInitExpr, source_instr); |
| 14880 | | ContainerInitKind init_kind = decl_node->data.container_init_expr.kind; |
| 14881 | | uint32_t field_count = actual_type->data.structure.src_field_count; |
| 14882 | | if (wanted_type->id == ZigTypeIdArray && (init_kind == ContainerInitKindArray || field_count == 0) && |
| 14878 | const bool is_array_init = |
| 14879 | actual_type->data.structure.special == StructSpecialInferredTuple; |
| 14880 | const uint32_t field_count = actual_type->data.structure.src_field_count; |
| 14881 | |
| 14882 | if (wanted_type->id == ZigTypeIdArray && (is_array_init || field_count == 0) && |
| 14883 | 14883 | wanted_type->data.array.len == field_count) |
| 14884 | 14884 | { |
| 14885 | 14885 | return ir_analyze_struct_literal_to_array(ira, source_instr, value, wanted_type); |
| 14886 | 14886 | } else if (wanted_type->id == ZigTypeIdStruct && |
| 14887 | | (init_kind == ContainerInitKindStruct || field_count == 0)) |
| 14887 | (!is_array_init || field_count == 0)) |
| 14888 | 14888 | { |
| 14889 | 14889 | return ir_analyze_struct_literal_to_struct(ira, source_instr, value, wanted_type); |
| 14890 | | } else if (wanted_type->id == ZigTypeIdUnion && init_kind == ContainerInitKindStruct && field_count == 1) { |
| 14890 | } else if (wanted_type->id == ZigTypeIdUnion && !is_array_init && field_count == 1) { |
| 14891 | 14891 | return ir_analyze_struct_literal_to_union(ira, source_instr, value, wanted_type); |
| 14892 | 14892 | } |
| 14893 | 14893 | } |