| ... | @@ -18477,15 +18477,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr | ... | @@ -18477,15 +18477,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18477 | IrInstGen *casted_ptr; | 18477 | IrInstGen *casted_ptr; |
| 18478 | if (isf->already_resolved) { | 18478 | if (isf->already_resolved) { |
| 18479 | field = find_struct_type_field(isf->inferred_struct_type, isf->field_name); | 18479 | field = find_struct_type_field(isf->inferred_struct_type, isf->field_name); |
| 18480 | | | |
| 18481 | // If the value originates from another node than the original value's we overwrite the inferred struct's | | |
| 18482 | // type so that the new result can be written successfully. | | |
| 18483 | // The duplicate field will be detected and reported in 'ir_analyze_container_init_fields' | | |
| 18484 | AstNode *decl_node = value ? value->base.source_node : suspend_source_instr->source_node; | | |
| 18485 | if (decl_node != field->decl_node) { | | |
| 18486 | field->type_entry = value_type; | | |
| 18487 | field->type_val = create_const_type(ira->codegen, field->type_entry); | | |
| 18488 | } | | |
| 18489 | casted_ptr = result_loc; | 18480 | casted_ptr = result_loc; |
| 18490 | } else { | 18481 | } else { |
| 18491 | isf->already_resolved = true; | 18482 | isf->already_resolved = true; |
| ... | @@ -18502,6 +18493,15 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr | ... | @@ -18502,6 +18493,15 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18502 | field->type_val = create_const_type(ira->codegen, field->type_entry); | 18493 | field->type_val = create_const_type(ira->codegen, field->type_entry); |
| 18503 | field->src_index = old_field_count; | 18494 | field->src_index = old_field_count; |
| 18504 | field->decl_node = value ? value->base.source_node : suspend_source_instr->source_node; | 18495 | field->decl_node = value ? value->base.source_node : suspend_source_instr->source_node; |
| | 18496 | if (value && instr_is_comptime(value)) { |
| | 18497 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); |
| | 18498 | if (!val) |
| | 18499 | return ira->codegen->invalid_inst_gen; |
| | 18500 | field->is_comptime = true; |
| | 18501 | field->init_val = ira->codegen->pass1_arena->create<ZigValue>(); |
| | 18502 | copy_const_val(ira->codegen, field->init_val, val); |
| | 18503 | return result_loc; |
| | 18504 | } |
| 18505 | | 18505 | |
| 18506 | ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false); | 18506 | ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false); |
| 18507 | if (instr_is_comptime(result_loc)) { | 18507 | if (instr_is_comptime(result_loc)) { |
| ... | @@ -18532,16 +18532,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr | ... | @@ -18532,16 +18532,6 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr |
| 18532 | } | 18532 | } |
| 18533 | } | 18533 | } |
| 18534 | | 18534 | |
| 18535 | if (value && instr_is_comptime(value)) { | | |
| 18536 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); | | |
| 18537 | if (!val) | | |
| 18538 | return ira->codegen->invalid_inst_gen; | | |
| 18539 | field->is_comptime = true; | | |
| 18540 | field->init_val = ira->codegen->pass1_arena->create<ZigValue>(); | | |
| 18541 | copy_const_val(ira->codegen, field->init_val, val); | | |
| 18542 | return result_loc; | | |
| 18543 | } | | |
| 18544 | | | |
| 18545 | result_loc = ir_analyze_struct_field_ptr(ira, suspend_source_instr, field, casted_ptr, | 18535 | result_loc = ir_analyze_struct_field_ptr(ira, suspend_source_instr, field, casted_ptr, |
| 18546 | isf->inferred_struct_type, true); | 18536 | isf->inferred_struct_type, true); |
| 18547 | result_loc_pass1->resolved_loc = result_loc; | 18537 | result_loc_pass1->resolved_loc = result_loc; |
| ... | @@ -22967,9 +22957,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc | ... | @@ -22967,9 +22957,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc |
| 22967 | first_non_const_instruction = result_loc; | 22957 | first_non_const_instruction = result_loc; |
| 22968 | } | 22958 | } |
| 22969 | } | 22959 | } |
| 22970 | | | |
| 22971 | heap::c_allocator.deallocate(field_assign_nodes, actual_field_count); | | |
| 22972 | | | |
| 22973 | if (any_missing) | 22960 | if (any_missing) |
| 22974 | return ira->codegen->invalid_inst_gen; | 22961 | return ira->codegen->invalid_inst_gen; |
| 22975 | | 22962 | |
| ... | @@ -22985,8 +22972,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc | ... | @@ -22985,8 +22972,6 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc |
| 22985 | } | 22972 | } |
| 22986 | } | 22973 | } |
| 22987 | | 22974 | |
| 22988 | const_ptrs.deinit(); | | |
| 22989 | | | |
| 22990 | IrInstGen *result = ir_get_deref(ira, source_instr, result_loc, nullptr); | 22975 | IrInstGen *result = ir_get_deref(ira, source_instr, result_loc, nullptr); |
| 22991 | | 22976 | |
| 22992 | if (is_comptime && !instr_is_comptime(result)) { | 22977 | if (is_comptime && !instr_is_comptime(result)) { |