| ... | ... | @@ -5686,7 +5686,13 @@ static bool can_mutate_comptime_var_state(ZigValue *value) { |
| 5686 | 5686 | zig_unreachable(); |
| 5687 | 5687 | case ZigTypeIdStruct: |
| 5688 | 5688 | for (uint32_t i = 0; i < value->type->data.structure.src_field_count; i += 1) { |
| 5689 | | if (can_mutate_comptime_var_state(value->data.x_struct.fields[i])) |
| 5689 | TypeStructField *type_struct_field = value->type->data.structure.fields[i]; |
| 5690 | |
| 5691 | ZigValue *field_value = type_struct_field->is_comptime ? |
| 5692 | type_struct_field->init_val : |
| 5693 | value->data.x_struct.fields[i]; |
| 5694 | |
| 5695 | if (can_mutate_comptime_var_state(field_value)) |
| 5690 | 5696 | return true; |
| 5691 | 5697 | } |
| 5692 | 5698 | return false; |
| ... | ... | @@ -9690,6 +9696,11 @@ void copy_const_val(CodeGen *g, ZigValue *dest, ZigValue *src) { |
| 9690 | 9696 | if (dest->type->id == ZigTypeIdStruct) { |
| 9691 | 9697 | dest->data.x_struct.fields = alloc_const_vals_ptrs(g, dest->type->data.structure.src_field_count); |
| 9692 | 9698 | for (size_t i = 0; i < dest->type->data.structure.src_field_count; i += 1) { |
| 9699 | TypeStructField *type_struct_field = dest->type->data.structure.fields[i]; |
| 9700 | // comptime-known values are stored in the field init_val inside |
| 9701 | // the struct type. |
| 9702 | if (type_struct_field->is_comptime) |
| 9703 | continue; |
| 9693 | 9704 | copy_const_val(g, dest->data.x_struct.fields[i], src->data.x_struct.fields[i]); |
| 9694 | 9705 | dest->data.x_struct.fields[i]->parent.id = ConstParentIdStruct; |
| 9695 | 9706 | dest->data.x_struct.fields[i]->parent.data.p_struct.struct_val = dest; |