| ... | @@ -17259,10 +17259,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17259,10 +17259,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17259 | const vals = try sema.arena.alloc(InternPool.Index, names.len); | 17259 | const vals = try sema.arena.alloc(InternPool.Index, names.len); |
| 17260 | for (vals, 0..) |*field_val, i| { | 17260 | for (vals, 0..) |*field_val, i| { |
| 17261 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17261 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17262 | const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i])); | 17262 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(names.get(ip)[i])); |
| 17263 | const name_val = v: { | 17263 | const name_val = v: { |
| 17264 | const new_decl_ty = try mod.arrayType(.{ | 17264 | const new_decl_ty = try mod.arrayType(.{ |
| 17265 | .len = name.len, | 17265 | .len = name.len, |
| | 17266 | .sentinel = .zero_u8, |
| 17266 | .child = .u8_type, | 17267 | .child = .u8_type, |
| 17267 | }); | 17268 | }); |
| 17268 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17269 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17270,17 +17271,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17270,17 +17271,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17270 | .storage = .{ .bytes = name }, | 17271 | .storage = .{ .bytes = name }, |
| 17271 | } }); | 17272 | } }); |
| 17272 | break :v try mod.intern(.{ .ptr = .{ | 17273 | break :v try mod.intern(.{ .ptr = .{ |
| 17273 | .ty = .slice_const_u8_type, | 17274 | .ty = .slice_const_u8_sentinel_0_type, |
| 17274 | .addr = .{ .anon_decl = .{ | 17275 | .addr = .{ .anon_decl = .{ |
| 17275 | .val = new_decl_val, | 17276 | .val = new_decl_val, |
| 17276 | .orig_ty = .slice_const_u8_type, | 17277 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17277 | } }, | 17278 | } }, |
| 17278 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17279 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17279 | } }); | 17280 | } }); |
| 17280 | }; | 17281 | }; |
| 17281 | | 17282 | |
| 17282 | const error_field_fields = .{ | 17283 | const error_field_fields = .{ |
| 17283 | // name: []const u8, | 17284 | // name: [:0]const u8, |
| 17284 | name_val, | 17285 | name_val, |
| 17285 | }; | 17286 | }; |
| 17286 | field_val.* = try mod.intern(.{ .aggregate = .{ | 17287 | field_val.* = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17387,10 +17388,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17387,10 +17388,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17387 | else | 17388 | else |
| 17388 | (try mod.intValue(Type.comptime_int, i)).toIntern(); | 17389 | (try mod.intValue(Type.comptime_int, i)).toIntern(); |
| 17389 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17390 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17390 | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); | 17391 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); |
| 17391 | const name_val = v: { | 17392 | const name_val = v: { |
| 17392 | const new_decl_ty = try mod.arrayType(.{ | 17393 | const new_decl_ty = try mod.arrayType(.{ |
| 17393 | .len = name.len, | 17394 | .len = name.len, |
| | 17395 | .sentinel = .zero_u8, |
| 17394 | .child = .u8_type, | 17396 | .child = .u8_type, |
| 17395 | }); | 17397 | }); |
| 17396 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17398 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17398,17 +17400,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17398,17 +17400,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17398 | .storage = .{ .bytes = name }, | 17400 | .storage = .{ .bytes = name }, |
| 17399 | } }); | 17401 | } }); |
| 17400 | break :v try mod.intern(.{ .ptr = .{ | 17402 | break :v try mod.intern(.{ .ptr = .{ |
| 17401 | .ty = .slice_const_u8_type, | 17403 | .ty = .slice_const_u8_sentinel_0_type, |
| 17402 | .addr = .{ .anon_decl = .{ | 17404 | .addr = .{ .anon_decl = .{ |
| 17403 | .val = new_decl_val, | 17405 | .val = new_decl_val, |
| 17404 | .orig_ty = .slice_const_u8_type, | 17406 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17405 | } }, | 17407 | } }, |
| 17406 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17408 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17407 | } }); | 17409 | } }); |
| 17408 | }; | 17410 | }; |
| 17409 | | 17411 | |
| 17410 | const enum_field_fields = .{ | 17412 | const enum_field_fields = .{ |
| 17411 | // name: []const u8, | 17413 | // name: [:0]const u8, |
| 17412 | name_val, | 17414 | name_val, |
| 17413 | // value: comptime_int, | 17415 | // value: comptime_int, |
| 17414 | value_val, | 17416 | value_val, |
| ... | @@ -17512,10 +17514,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17512,10 +17514,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17512 | | 17514 | |
| 17513 | for (union_field_vals, 0..) |*field_val, i| { | 17515 | for (union_field_vals, 0..) |*field_val, i| { |
| 17514 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17516 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17515 | const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); | 17517 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); |
| 17516 | const name_val = v: { | 17518 | const name_val = v: { |
| 17517 | const new_decl_ty = try mod.arrayType(.{ | 17519 | const new_decl_ty = try mod.arrayType(.{ |
| 17518 | .len = name.len, | 17520 | .len = name.len, |
| | 17521 | .sentinel = .zero_u8, |
| 17519 | .child = .u8_type, | 17522 | .child = .u8_type, |
| 17520 | }); | 17523 | }); |
| 17521 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17524 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17523,10 +17526,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17523,10 +17526,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17523 | .storage = .{ .bytes = name }, | 17526 | .storage = .{ .bytes = name }, |
| 17524 | } }); | 17527 | } }); |
| 17525 | break :v try mod.intern(.{ .ptr = .{ | 17528 | break :v try mod.intern(.{ .ptr = .{ |
| 17526 | .ty = .slice_const_u8_type, | 17529 | .ty = .slice_const_u8_sentinel_0_type, |
| 17527 | .addr = .{ .anon_decl = .{ | 17530 | .addr = .{ .anon_decl = .{ |
| 17528 | .val = new_decl_val, | 17531 | .val = new_decl_val, |
| 17529 | .orig_ty = .slice_const_u8_type, | 17532 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17530 | } }, | 17533 | } }, |
| 17531 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17534 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17532 | } }); | 17535 | } }); |
| ... | @@ -17539,7 +17542,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17539,7 +17542,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17539 | | 17542 | |
| 17540 | const field_ty = union_obj.field_types.get(ip)[i]; | 17543 | const field_ty = union_obj.field_types.get(ip)[i]; |
| 17541 | const union_field_fields = .{ | 17544 | const union_field_fields = .{ |
| 17542 | // name: []const u8, | 17545 | // name: [:0]const u8, |
| 17543 | name_val, | 17546 | name_val, |
| 17544 | // type: type, | 17547 | // type: type, |
| 17545 | field_ty, | 17548 | field_ty, |
| ... | @@ -17658,11 +17661,12 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17658,11 +17661,12 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17658 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17661 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17659 | const bytes = if (tuple.names.len != 0) | 17662 | const bytes = if (tuple.names.len != 0) |
| 17660 | // https://github.com/ziglang/zig/issues/15709 | 17663 | // https://github.com/ziglang/zig/issues/15709 |
| 17661 | try sema.arena.dupe(u8, ip.stringToSlice(ip.indexToKey(ty.toIntern()).anon_struct_type.names.get(ip)[i])) | 17664 | try sema.arena.dupeZ(u8, ip.stringToSlice(ip.indexToKey(ty.toIntern()).anon_struct_type.names.get(ip)[i])) |
| 17662 | else | 17665 | else |
| 17663 | try std.fmt.allocPrint(sema.arena, "{d}", .{i}); | 17666 | try std.fmt.allocPrintZ(sema.arena, "{d}", .{i}); |
| 17664 | const new_decl_ty = try mod.arrayType(.{ | 17667 | const new_decl_ty = try mod.arrayType(.{ |
| 17665 | .len = bytes.len, | 17668 | .len = bytes.len, |
| | 17669 | .sentinel = .zero_u8, |
| 17666 | .child = .u8_type, | 17670 | .child = .u8_type, |
| 17667 | }); | 17671 | }); |
| 17668 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17672 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17670,10 +17674,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17670,10 +17674,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17670 | .storage = .{ .bytes = bytes }, | 17674 | .storage = .{ .bytes = bytes }, |
| 17671 | } }); | 17675 | } }); |
| 17672 | break :v try mod.intern(.{ .ptr = .{ | 17676 | break :v try mod.intern(.{ .ptr = .{ |
| 17673 | .ty = .slice_const_u8_type, | 17677 | .ty = .slice_const_u8_sentinel_0_type, |
| 17674 | .addr = .{ .anon_decl = .{ | 17678 | .addr = .{ .anon_decl = .{ |
| 17675 | .val = new_decl_val, | 17679 | .val = new_decl_val, |
| 17676 | .orig_ty = .slice_const_u8_type, | 17680 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17677 | } }, | 17681 | } }, |
| 17678 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), | 17682 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), |
| 17679 | } }); | 17683 | } }); |
| ... | @@ -17685,7 +17689,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17685,7 +17689,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17685 | const opt_default_val = if (is_comptime) Value.fromInterned(field_val) else null; | 17689 | const opt_default_val = if (is_comptime) Value.fromInterned(field_val) else null; |
| 17686 | const default_val_ptr = try sema.optRefValue(opt_default_val); | 17690 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 17687 | const struct_field_fields = .{ | 17691 | const struct_field_fields = .{ |
| 17688 | // name: []const u8, | 17692 | // name: [:0]const u8, |
| 17689 | name_val, | 17693 | name_val, |
| 17690 | // type: type, | 17694 | // type: type, |
| 17691 | field_ty, | 17695 | field_ty, |
| ... | @@ -17713,7 +17717,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17713,7 +17717,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17713 | for (struct_field_vals, 0..) |*field_val, i| { | 17717 | for (struct_field_vals, 0..) |*field_val, i| { |
| 17714 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17718 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17715 | const name = if (struct_type.fieldName(ip, i).unwrap()) |name_nts| | 17719 | const name = if (struct_type.fieldName(ip, i).unwrap()) |name_nts| |
| 17716 | try sema.arena.dupe(u8, ip.stringToSlice(name_nts)) | 17720 | try sema.arena.dupeZ(u8, ip.stringToSlice(name_nts)) |
| 17717 | else | 17721 | else |
| 17718 | try std.fmt.allocPrintZ(sema.arena, "{d}", .{i}); | 17722 | try std.fmt.allocPrintZ(sema.arena, "{d}", .{i}); |
| 17719 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); | 17723 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| ... | @@ -17722,6 +17726,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17722,6 +17726,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17722 | const name_val = v: { | 17726 | const name_val = v: { |
| 17723 | const new_decl_ty = try mod.arrayType(.{ | 17727 | const new_decl_ty = try mod.arrayType(.{ |
| 17724 | .len = name.len, | 17728 | .len = name.len, |
| | 17729 | .sentinel = .zero_u8, |
| 17725 | .child = .u8_type, | 17730 | .child = .u8_type, |
| 17726 | }); | 17731 | }); |
| 17727 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17732 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17729,10 +17734,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17729,10 +17734,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17729 | .storage = .{ .bytes = name }, | 17734 | .storage = .{ .bytes = name }, |
| 17730 | } }); | 17735 | } }); |
| 17731 | break :v try mod.intern(.{ .ptr = .{ | 17736 | break :v try mod.intern(.{ .ptr = .{ |
| 17732 | .ty = .slice_const_u8_type, | 17737 | .ty = .slice_const_u8_sentinel_0_type, |
| 17733 | .addr = .{ .anon_decl = .{ | 17738 | .addr = .{ .anon_decl = .{ |
| 17734 | .val = new_decl_val, | 17739 | .val = new_decl_val, |
| 17735 | .orig_ty = .slice_const_u8_type, | 17740 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17736 | } }, | 17741 | } }, |
| 17737 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17742 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17738 | } }); | 17743 | } }); |
| ... | @@ -17750,7 +17755,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17750,7 +17755,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17750 | }; | 17755 | }; |
| 17751 | | 17756 | |
| 17752 | const struct_field_fields = .{ | 17757 | const struct_field_fields = .{ |
| 17753 | // name: []const u8, | 17758 | // name: [:0]const u8, |
| 17754 | name_val, | 17759 | name_val, |
| 17755 | // type: type, | 17760 | // type: type, |
| 17756 | field_ty.toIntern(), | 17761 | field_ty.toIntern(), |
| ... | @@ -17957,9 +17962,10 @@ fn typeInfoNamespaceDecls( | ... | @@ -17957,9 +17962,10 @@ fn typeInfoNamespaceDecls( |
| 17957 | if (decl.kind != .named or !decl.is_pub) continue; | 17962 | if (decl.kind != .named or !decl.is_pub) continue; |
| 17958 | const name_val = v: { | 17963 | const name_val = v: { |
| 17959 | // TODO: write something like getCoercedInts to avoid needing to dupe | 17964 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17960 | const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name)); | 17965 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(decl.name)); |
| 17961 | const new_decl_ty = try mod.arrayType(.{ | 17966 | const new_decl_ty = try mod.arrayType(.{ |
| 17962 | .len = name.len, | 17967 | .len = name.len, |
| | 17968 | .sentinel = .zero_u8, |
| 17963 | .child = .u8_type, | 17969 | .child = .u8_type, |
| 17964 | }); | 17970 | }); |
| 17965 | const new_decl_val = try mod.intern(.{ .aggregate = .{ | 17971 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | @@ -17967,9 +17973,9 @@ fn typeInfoNamespaceDecls( | ... | @@ -17967,9 +17973,9 @@ fn typeInfoNamespaceDecls( |
| 17967 | .storage = .{ .bytes = name }, | 17973 | .storage = .{ .bytes = name }, |
| 17968 | } }); | 17974 | } }); |
| 17969 | break :v try mod.intern(.{ .ptr = .{ | 17975 | break :v try mod.intern(.{ .ptr = .{ |
| 17970 | .ty = .slice_const_u8_type, | 17976 | .ty = .slice_const_u8_sentinel_0_type, |
| 17971 | .addr = .{ .anon_decl = .{ | 17977 | .addr = .{ .anon_decl = .{ |
| 17972 | .orig_ty = .slice_const_u8_type, | 17978 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17973 | .val = new_decl_val, | 17979 | .val = new_decl_val, |
| 17974 | } }, | 17980 | } }, |
| 17975 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), | 17981 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| ... | @@ -17977,7 +17983,7 @@ fn typeInfoNamespaceDecls( | ... | @@ -17977,7 +17983,7 @@ fn typeInfoNamespaceDecls( |
| 17977 | }; | 17983 | }; |
| 17978 | | 17984 | |
| 17979 | const fields = .{ | 17985 | const fields = .{ |
| 17980 | //name: []const u8, | 17986 | //name: [:0]const u8, |
| 17981 | name_val, | 17987 | name_val, |
| 17982 | }; | 17988 | }; |
| 17983 | try decl_vals.append(try mod.intern(.{ .aggregate = .{ | 17989 | try decl_vals.append(try mod.intern(.{ .aggregate = .{ |