| ... | ... | @@ -5043,22 +5043,33 @@ fn zirValidatePtrArrayInit( |
| 5043 | 5043 | const array_ty = sema.typeOf(array_ptr).childType(mod).optEuBaseType(mod); |
| 5044 | 5044 | const array_len = array_ty.arrayLen(mod); |
| 5045 | 5045 | |
| 5046 | // Collect the comptime element values in case the array literal ends up |
| 5047 | // being comptime-known. |
| 5048 | const element_vals = try sema.arena.alloc( |
| 5049 | InternPool.Index, |
| 5050 | try sema.usizeCast(block, init_src, array_len), |
| 5051 | ); |
| 5052 | |
| 5046 | 5053 | if (instrs.len != array_len) switch (array_ty.zigTypeTag(mod)) { |
| 5047 | 5054 | .Struct => { |
| 5048 | 5055 | var root_msg: ?*Module.ErrorMsg = null; |
| 5049 | 5056 | errdefer if (root_msg) |msg| msg.destroy(sema.gpa); |
| 5050 | 5057 | |
| 5058 | try sema.resolveStructFieldInits(array_ty); |
| 5051 | 5059 | var i = instrs.len; |
| 5052 | 5060 | while (i < array_len) : (i += 1) { |
| 5053 | | const default_val = array_ty.structFieldDefaultValue(i, mod); |
| 5054 | | if (default_val.toIntern() == .unreachable_value) { |
| 5061 | const default_val = array_ty.structFieldDefaultValue(i, mod).toIntern(); |
| 5062 | if (default_val == .unreachable_value) { |
| 5055 | 5063 | const template = "missing tuple field with index {d}"; |
| 5056 | 5064 | if (root_msg) |msg| { |
| 5057 | 5065 | try sema.errNote(block, init_src, msg, template, .{i}); |
| 5058 | 5066 | } else { |
| 5059 | 5067 | root_msg = try sema.errMsg(block, init_src, template, .{i}); |
| 5060 | 5068 | } |
| 5069 | continue; |
| 5061 | 5070 | } |
| 5071 | |
| 5072 | element_vals[i] = default_val; |
| 5062 | 5073 | } |
| 5063 | 5074 | |
| 5064 | 5075 | if (root_msg) |msg| { |
| ... | ... | @@ -5105,12 +5116,6 @@ fn zirValidatePtrArrayInit( |
| 5105 | 5116 | var array_is_comptime = true; |
| 5106 | 5117 | var first_block_index = block.instructions.items.len; |
| 5107 | 5118 | |
| 5108 | | // Collect the comptime element values in case the array literal ends up |
| 5109 | | // being comptime-known. |
| 5110 | | const element_vals = try sema.arena.alloc( |
| 5111 | | InternPool.Index, |
| 5112 | | try sema.usizeCast(block, init_src, array_len), |
| 5113 | | ); |
| 5114 | 5119 | const air_tags = sema.air_instructions.items(.tag); |
| 5115 | 5120 | const air_datas = sema.air_instructions.items(.data); |
| 5116 | 5121 | |