From 442592855c655f20b8b51db9ac75e17485c4e685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Prokop=20Rand=C3=A1=C4=8Dek?= Date: Fri, 21 Nov 2025 08:24:16 +0100 Subject: [PATCH] change placeholder pattern in deduplicated type errors --- src/Type.zig | 6 +++--- ...checked_when_coercing_pointer_to_anon_literal.zig | 3 +-- test/cases/compile_errors/type_dedupe.zig | 12 ++++++------ .../type_mismatch_with_tuple_concatenation.zig | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Type.zig b/src/Type.zig index 5577d82335..a36bca94b9 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -4158,8 +4158,8 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe const type_len: i32 = @intCast(discarding.count); - const placeholder_len: i32 = 3; - const min_saved_bytes: i32 = 10; + const placeholder_len: i32 = 1; + const min_saved_bytes: i32 = 20; const saved_bytes = (type_len - placeholder_len) * (occ - 1); const max_placeholders = 7; // T to Z @@ -4192,7 +4192,7 @@ pub const Comparison = struct { index: u8, pub fn format(p: Placeholder, writer: *std.Io.Writer) error{WriteFailed}!void { - return writer.print("<{c}>", .{p.index + 'T'}); + return writer.print("{c}", .{p.index + 'T'}); } }; diff --git a/test/cases/compile_errors/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig b/test/cases/compile_errors/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig index 12ecf98590..00693a87f0 100644 --- a/test/cases/compile_errors/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig +++ b/test/cases/compile_errors/pointer_attributes_checked_when_coercing_pointer_to_anon_literal.zig @@ -16,8 +16,7 @@ comptime { // // :2:29: error: expected type '[][]const u8', found '*const [2][]const u8' // :2:29: note: cast discards const qualifier -// :6:31: error: expected type '*', found '*const ' -// :6:31: note: = [2][]const u8 +// :6:31: error: expected type '*[2][]const u8', found '*const [2][]const u8' // :6:31: note: cast discards const qualifier // :11:19: error: expected type '*tmp.S', found '*const tmp.S' // :11:19: note: cast discards const qualifier diff --git a/test/cases/compile_errors/type_dedupe.zig b/test/cases/compile_errors/type_dedupe.zig index d1787d0bfa..23174dc89a 100644 --- a/test/cases/compile_errors/type_dedupe.zig +++ b/test/cases/compile_errors/type_dedupe.zig @@ -1,18 +1,18 @@ -const SomeVeryLongName = struct {}; +const SomeVeryVeryVeryLongName = struct {}; -fn foo(a: *SomeVeryLongName) void { +fn foo(a: *SomeVeryVeryVeryLongName) void { _ = a; } export fn entry() void { - const a: SomeVeryLongName = .{}; + const a: SomeVeryVeryVeryLongName = .{}; foo(a); } // error // -// :10:9: error: expected type '*', found '' -// :10:9: note: = tmp.SomeVeryLongName -// :1:26: note: struct declared here +// :10:9: error: expected type '*T', found 'T' +// :10:9: note: T = tmp.SomeVeryVeryVeryLongName +// :1:34: note: struct declared here // :3:11: note: parameter type declared here diff --git a/test/cases/compile_errors/type_mismatch_with_tuple_concatenation.zig b/test/cases/compile_errors/type_mismatch_with_tuple_concatenation.zig index bb6ee8ba33..151966f07b 100644 --- a/test/cases/compile_errors/type_mismatch_with_tuple_concatenation.zig +++ b/test/cases/compile_errors/type_mismatch_with_tuple_concatenation.zig @@ -5,5 +5,5 @@ export fn entry() void { // error // -// :3:11: error: expected type '@TypeOf(.{})', found 'struct { comptime = 1, comptime = 2, comptime = 3 }' -// :3:11: note: = comptime_int +// :3:11: error: expected type '@TypeOf(.{})', found 'struct { comptime T = 1, comptime T = 2, comptime T = 3 }' +// :3:11: note: T = comptime_int