| ... | @@ -16833,7 +16833,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -16833,7 +16833,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 16833 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 16833 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 16834 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 16834 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 16835 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, | 16835 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, |
| 16836 | elem_ptr_instruction->ptr_len, true); | 16836 | elem_ptr_instruction->ptr_len, false); |
| 16837 | result->value.type = return_type; | 16837 | result->value.type = return_type; |
| 16838 | return result; | 16838 | return result; |
| 16839 | } | 16839 | } |
| ... | @@ -16898,15 +16898,6 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -16898,15 +16898,6 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 16898 | } | 16898 | } |
| 16899 | } | 16899 | } |
| 16900 | } | 16900 | } |
| 16901 | | | |
| 16902 | if (is_slice(array_type) && elem_ptr_instruction->initializing) { | | |
| 16903 | // we need a pointer to an element inside a slice. but we're initializing an array. | | |
| 16904 | // this means that the slice isn't actually pointing at anything. | | |
| 16905 | ir_add_error(ira, &elem_ptr_instruction->base, | | |
| 16906 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", | | |
| 16907 | buf_ptr(&array_type->name))); | | |
| 16908 | return ira->codegen->invalid_instruction; | | |
| 16909 | } | | |
| 16910 | } else { | 16901 | } else { |
| 16911 | // runtime known element index | 16902 | // runtime known element index |
| 16912 | switch (type_requires_comptime(ira->codegen, return_type)) { | 16903 | switch (type_requires_comptime(ira->codegen, return_type)) { |
| ... | @@ -19053,6 +19044,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -19053,6 +19044,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 19053 | IrInstruction *result_loc = instruction->result_loc->child; | 19044 | IrInstruction *result_loc = instruction->result_loc->child; |
| 19054 | if (type_is_invalid(result_loc->value.type)) | 19045 | if (type_is_invalid(result_loc->value.type)) |
| 19055 | return result_loc; | 19046 | return result_loc; |
| | 19047 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base); |
| | 19048 | ZigType *result_elem_type = result_loc->value.type->data.pointer.child_type; |
| | 19049 | if (is_slice(result_elem_type)) { |
| | 19050 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| | 19051 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", |
| | 19052 | buf_ptr(&result_elem_type->name))); |
| | 19053 | add_error_note(ira->codegen, msg, first_non_const_instruction->source_node, |
| | 19054 | buf_sprintf("this value is not comptime-known")); |
| | 19055 | return ira->codegen->invalid_instruction; |
| | 19056 | } |
| 19056 | return ir_get_deref(ira, &instruction->base, result_loc, nullptr); | 19057 | return ir_get_deref(ira, &instruction->base, result_loc, nullptr); |
| 19057 | } else if (container_type->id == ZigTypeIdVoid) { | 19058 | } else if (container_type->id == ZigTypeIdVoid) { |
| 19058 | if (elem_count != 0) { | 19059 | if (elem_count != 0) { |