| ... | @@ -5401,6 +5401,8 @@ bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b) { | ... | @@ -5401,6 +5401,8 @@ bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b) { |
| 5401 | | 5401 | |
| 5402 | static bool can_mutate_comptime_var_state(ZigValue *value) { | 5402 | static bool can_mutate_comptime_var_state(ZigValue *value) { |
| 5403 | assert(value != nullptr); | 5403 | assert(value != nullptr); |
| | 5404 | if (value->special == ConstValSpecialUndef) |
| | 5405 | return false; |
| 5404 | switch (value->type->id) { | 5406 | switch (value->type->id) { |
| 5405 | case ZigTypeIdInvalid: | 5407 | case ZigTypeIdInvalid: |
| 5406 | zig_unreachable(); | 5408 | zig_unreachable(); |
| ... | @@ -6701,8 +6703,16 @@ bool const_values_equal_ptr(ZigValue *a, ZigValue *b) { | ... | @@ -6701,8 +6703,16 @@ bool const_values_equal_ptr(ZigValue *a, ZigValue *b) { |
| 6701 | } | 6703 | } |
| 6702 | | 6704 | |
| 6703 | static bool const_values_equal_array(CodeGen *g, ZigValue *a, ZigValue *b, size_t len) { | 6705 | static bool const_values_equal_array(CodeGen *g, ZigValue *a, ZigValue *b, size_t len) { |
| 6704 | assert(a->data.x_array.special != ConstArraySpecialUndef); | 6706 | if (a->data.x_array.special == ConstArraySpecialUndef && |
| 6705 | assert(b->data.x_array.special != ConstArraySpecialUndef); | 6707 | b->data.x_array.special == ConstArraySpecialUndef) |
| | 6708 | { |
| | 6709 | return true; |
| | 6710 | } |
| | 6711 | if (a->data.x_array.special == ConstArraySpecialUndef || |
| | 6712 | b->data.x_array.special == ConstArraySpecialUndef) |
| | 6713 | { |
| | 6714 | return false; |
| | 6715 | } |
| 6706 | if (a->data.x_array.special == ConstArraySpecialBuf && | 6716 | if (a->data.x_array.special == ConstArraySpecialBuf && |
| 6707 | b->data.x_array.special == ConstArraySpecialBuf) | 6717 | b->data.x_array.special == ConstArraySpecialBuf) |
| 6708 | { | 6718 | { |
| ... | @@ -9390,13 +9400,24 @@ void copy_const_val(CodeGen *g, ZigValue *dest, ZigValue *src) { | ... | @@ -9390,13 +9400,24 @@ void copy_const_val(CodeGen *g, ZigValue *dest, ZigValue *src) { |
| 9390 | dest->data.x_struct.fields[i]->parent.data.p_struct.field_index = i; | 9400 | dest->data.x_struct.fields[i]->parent.data.p_struct.field_index = i; |
| 9391 | } | 9401 | } |
| 9392 | } else if (dest->type->id == ZigTypeIdArray) { | 9402 | } else if (dest->type->id == ZigTypeIdArray) { |
| 9393 | if (dest->data.x_array.special == ConstArraySpecialNone) { | 9403 | switch (dest->data.x_array.special) { |
| 9394 | dest->data.x_array.data.s_none.elements = g->pass1_arena->allocate<ZigValue>(dest->type->data.array.len); | 9404 | case ConstArraySpecialNone: { |
| 9395 | for (uint64_t i = 0; i < dest->type->data.array.len; i += 1) { | 9405 | dest->data.x_array.data.s_none.elements = g->pass1_arena->allocate<ZigValue>(dest->type->data.array.len); |
| 9396 | copy_const_val(g, &dest->data.x_array.data.s_none.elements[i], &src->data.x_array.data.s_none.elements[i]); | 9406 | for (uint64_t i = 0; i < dest->type->data.array.len; i += 1) { |
| 9397 | dest->data.x_array.data.s_none.elements[i].parent.id = ConstParentIdArray; | 9407 | copy_const_val(g, &dest->data.x_array.data.s_none.elements[i], &src->data.x_array.data.s_none.elements[i]); |
| 9398 | dest->data.x_array.data.s_none.elements[i].parent.data.p_array.array_val = dest; | 9408 | dest->data.x_array.data.s_none.elements[i].parent.id = ConstParentIdArray; |
| 9399 | dest->data.x_array.data.s_none.elements[i].parent.data.p_array.elem_index = i; | 9409 | dest->data.x_array.data.s_none.elements[i].parent.data.p_array.array_val = dest; |
| | 9410 | dest->data.x_array.data.s_none.elements[i].parent.data.p_array.elem_index = i; |
| | 9411 | } |
| | 9412 | break; |
| | 9413 | } |
| | 9414 | case ConstArraySpecialUndef: { |
| | 9415 | // Nothing to copy; the above memcpy did everything we needed. |
| | 9416 | break; |
| | 9417 | } |
| | 9418 | case ConstArraySpecialBuf: { |
| | 9419 | dest->data.x_array.data.s_buf = buf_create_from_buf(src->data.x_array.data.s_buf); |
| | 9420 | break; |
| 9400 | } | 9421 | } |
| 9401 | } | 9422 | } |
| 9402 | } else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) { | 9423 | } else if (type_has_optional_repr(dest->type) && dest->data.x_optional != nullptr) { |