| ... | ... | @@ -31867,14 +31867,9 @@ fn coerceTupleToStruct( |
| 31867 | 31867 | }; |
| 31868 | 31868 | for (0..field_count) |tuple_field_index| { |
| 31869 | 31869 | const field_src = inst_src; // TODO better source location |
| 31870 | | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { |
| 31871 | | .anon_struct_type => |anon_struct_type| if (anon_struct_type.names.len > 0) |
| 31872 | | anon_struct_type.names.get(ip)[tuple_field_index] |
| 31873 | | else |
| 31874 | | try ip.getOrPutStringFmt(sema.gpa, pt.tid, "{d}", .{tuple_field_index}, .no_embedded_nulls), |
| 31875 | | .struct_type => ip.loadStructType(inst_ty.toIntern()).field_names.get(ip)[tuple_field_index], |
| 31876 | | else => unreachable, |
| 31877 | | }; |
| 31870 | const field_name = inst_ty.structFieldName(tuple_field_index, mod).unwrap() orelse |
| 31871 | try ip.getOrPutStringFmt(sema.gpa, pt.tid, "{d}", .{tuple_field_index}, .no_embedded_nulls); |
| 31872 | |
| 31878 | 31873 | const struct_field_index = try sema.structFieldIndex(block, struct_ty, field_name, field_src); |
| 31879 | 31874 | const struct_field_ty = Type.fromInterned(struct_type.field_types.get(ip)[struct_field_index]); |
| 31880 | 31875 | const elem_ref = try sema.tupleField(block, inst_src, inst, field_src, @intCast(tuple_field_index)); |
| ... | ... | @@ -31980,21 +31975,8 @@ fn coerceTupleToTuple( |
| 31980 | 31975 | for (0..dest_field_count) |field_index_usize| { |
| 31981 | 31976 | const field_i: u32 = @intCast(field_index_usize); |
| 31982 | 31977 | const field_src = inst_src; // TODO better source location |
| 31983 | | const field_name: InternPool.NullTerminatedString = switch (ip.indexToKey(inst_ty.toIntern())) { |
| 31984 | | .anon_struct_type => |anon_struct_type| if (anon_struct_type.names.len > 0) |
| 31985 | | anon_struct_type.names.get(ip)[field_i] |
| 31986 | | else |
| 31987 | | try ip.getOrPutStringFmt(sema.gpa, pt.tid, "{d}", .{field_i}, .no_embedded_nulls), |
| 31988 | | .struct_type => s: { |
| 31989 | | const struct_type = ip.loadStructType(inst_ty.toIntern()); |
| 31990 | | if (struct_type.field_names.len > 0) { |
| 31991 | | break :s struct_type.field_names.get(ip)[field_i]; |
| 31992 | | } else { |
| 31993 | | break :s try ip.getOrPutStringFmt(sema.gpa, pt.tid, "{d}", .{field_i}, .no_embedded_nulls); |
| 31994 | | } |
| 31995 | | }, |
| 31996 | | else => unreachable, |
| 31997 | | }; |
| 31978 | const field_name = inst_ty.structFieldName(field_index_usize, mod).unwrap() orelse |
| 31979 | try ip.getOrPutStringFmt(sema.gpa, pt.tid, "{d}", .{field_index_usize}, .no_embedded_nulls); |
| 31998 | 31980 | |
| 31999 | 31981 | if (field_name.eqlSlice("len", ip)) |
| 32000 | 31982 | return sema.fail(block, field_src, "cannot assign to 'len' field of tuple", .{}); |