authorgravatar for prokop@rdck.devProkop Randáček <prokop@rdck.dev> 2025-11-21 08:24:16+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-20 08:06:59+01:00
log442592855c655f20b8b51db9ac75e17485c4e685
tree486b7f9f565bfb399fc41fad3225536bb3ffbf56
parent5fa7f13082145c10d0b536cc894f60323ffacd61

change placeholder pattern in deduplicated type errors


4 files changed, 12 insertions(+), 13 deletions(-)

src/Type.zig+3-3
......@@ -4158,8 +4158,8 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe
41584158
41594159 const type_len: i32 = @intCast(discarding.count);
41604160
4161 const placeholder_len: i32 = 3;
4162 const min_saved_bytes: i32 = 10;
4161 const placeholder_len: i32 = 1;
4162 const min_saved_bytes: i32 = 20;
41634163
41644164 const saved_bytes = (type_len - placeholder_len) * (occ - 1);
41654165 const max_placeholders = 7; // T to Z
......@@ -4192,7 +4192,7 @@ pub const Comparison = struct {
41924192 index: u8,
41934193
41944194 pub fn format(p: Placeholder, writer: *std.Io.Writer) error{WriteFailed}!void {
4195 return writer.print("<{c}>", .{p.index + 'T'});
4195 return writer.print("{c}", .{p.index + 'T'});
41964196 }
41974197 };
41984198
test/cases/compile_errors/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig+1-2
......@@ -16,8 +16,7 @@ comptime {
1616//
1717// :2:29: error: expected type '[][]const u8', found '*const [2][]const u8'
1818// :2:29: note: cast discards const qualifier
19// :6:31: error: expected type '*<T>', found '*const <T>'
20// :6:31: note: <T> = [2][]const u8
19// :6:31: error: expected type '*[2][]const u8', found '*const [2][]const u8'
2120// :6:31: note: cast discards const qualifier
2221// :11:19: error: expected type '*tmp.S', found '*const tmp.S'
2322// :11:19: note: cast discards const qualifier
test/cases/compile_errors/type_dedupe.zig+6-6
......@@ -1,18 +1,18 @@
1const SomeVeryLongName = struct {};
1const SomeVeryVeryVeryLongName = struct {};
22
3fn foo(a: *SomeVeryLongName) void {
3fn foo(a: *SomeVeryVeryVeryLongName) void {
44 _ = a;
55}
66
77export fn entry() void {
8 const a: SomeVeryLongName = .{};
8 const a: SomeVeryVeryVeryLongName = .{};
99
1010 foo(a);
1111}
1212
1313// error
1414//
15// :10:9: error: expected type '*<T>', found '<T>'
16// :10:9: note: <T> = tmp.SomeVeryLongName
17// :1:26: note: struct declared here
15// :10:9: error: expected type '*T', found 'T'
16// :10:9: note: T = tmp.SomeVeryVeryVeryLongName
17// :1:34: note: struct declared here
1818// :3:11: note: parameter type declared here
test/cases/compile_errors/type_mismatch_with_tuple_concatenation.zig+2-2
......@@ -5,5 +5,5 @@ export fn entry() void {
55
66// error
77//
8// :3:11: error: expected type '@TypeOf(.{})', found 'struct { comptime <T> = 1, comptime <T> = 2, comptime <T> = 3 }'
9// :3:11: note: <T> = comptime_int
8// :3:11: error: expected type '@TypeOf(.{})', found 'struct { comptime T = 1, comptime T = 2, comptime T = 3 }'
9// :3:11: note: T = comptime_int