| ... | @@ -26261,13 +26261,16 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i | ... | @@ -26261,13 +26261,16 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 26261 | return ira->codegen->invalid_inst_gen; | 26261 | return ira->codegen->invalid_inst_gen; |
| 26262 | } | 26262 | } |
| 26263 | | 26263 | |
| | 26264 | ZigType *child_array_type = (array_type->id == ZigTypeIdPointer && |
| | 26265 | array_type->data.pointer.ptr_len == PtrLenSingle) ? array_type->data.pointer.child_type : array_type; |
| | 26266 | |
| 26264 | // If start index and end index are both comptime known, then the result type is a pointer to array | 26267 | // If start index and end index are both comptime known, then the result type is a pointer to array |
| 26265 | // not a slice. | 26268 | // not a slice. |
| 26266 | ZigType *return_type; | 26269 | ZigType *return_type; |
| 26267 | | 26270 | |
| 26268 | if (value_is_comptime(casted_start->value) && | 26271 | if (value_is_comptime(casted_start->value) && |
| 26269 | ((end != nullptr && value_is_comptime(end->value)) || | 26272 | ((end != nullptr && value_is_comptime(end->value)) || |
| 26270 | (end == nullptr && array_type->id == ZigTypeIdArray))) | 26273 | (end == nullptr && child_array_type->id == ZigTypeIdArray))) |
| 26271 | { | 26274 | { |
| 26272 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); | 26275 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); |
| 26273 | if (!start_val) | 26276 | if (!start_val) |
| ... | @@ -26282,10 +26285,11 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i | ... | @@ -26282,10 +26285,11 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 26282 | return ira->codegen->invalid_inst_gen; | 26285 | return ira->codegen->invalid_inst_gen; |
| 26283 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); | 26286 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); |
| 26284 | } else { | 26287 | } else { |
| 26285 | end_scalar = array_type->data.array.len; | 26288 | end_scalar = child_array_type->data.array.len; |
| 26286 | } | 26289 | } |
| 26287 | ZigValue *array_sentinel = (array_type->id == ZigTypeIdArray && end_scalar == array_type->data.array.len) | 26290 | ZigValue *array_sentinel = (child_array_type->id == ZigTypeIdArray && |
| 26288 | ? sentinel_val : nullptr; | 26291 | end_scalar == child_array_type->data.array.len) |
| | 26292 | ? child_array_type->data.array.sentinel : nullptr; |
| 26289 | | 26293 | |
| 26290 | if (start_scalar > end_scalar) { | 26294 | if (start_scalar > end_scalar) { |
| 26291 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); | 26295 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); |
| ... | @@ -26318,12 +26322,8 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i | ... | @@ -26318,12 +26322,8 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i |
| 26318 | size_t abs_offset; | 26322 | size_t abs_offset; |
| 26319 | size_t rel_end; | 26323 | size_t rel_end; |
| 26320 | bool ptr_is_undef = false; | 26324 | bool ptr_is_undef = false; |
| 26321 | if (array_type->id == ZigTypeIdArray || | 26325 | if (child_array_type->id == ZigTypeIdArray) { |
| 26322 | (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle)) | | |
| 26323 | { | | |
| 26324 | if (array_type->id == ZigTypeIdPointer) { | 26326 | if (array_type->id == ZigTypeIdPointer) { |
| 26325 | ZigType *child_array_type = array_type->data.pointer.child_type; | | |
| 26326 | assert(child_array_type->id == ZigTypeIdArray); | | |
| 26327 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); | 26327 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 26328 | if (parent_ptr == nullptr) | 26328 | if (parent_ptr == nullptr) |
| 26329 | return ira->codegen->invalid_inst_gen; | 26329 | return ira->codegen->invalid_inst_gen; |