From c9531eb833e1e2c432dc2bfb0ca3b25622b7001e Mon Sep 17 00:00:00 2001 From: mlugg Date: Tue, 13 Jun 2023 15:17:31 +0100 Subject: Sema: rewrite peer type resolution The existing logic for peer type resolution was quite convoluted and buggy. This rewrite makes it much more resilient, readable, and extensible. The algorithm works by first iterating over the types to select a "strategy", then applying that strategy, possibly applying peer resolution recursively. Several new tests have been added to cover cases which the old logic did not correctly handle. Resolves: #15138 Resolves: #15644 Resolves: #15693 Resolves: #15709 Resolves: #15752 --- src/Module.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index d60f3919a5..e8cea97b8f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -6978,7 +6978,7 @@ pub fn intBitsForValue(mod: *Module, val: Value, sign: bool) u16 { assert(sign); // Protect against overflow in the following negation. if (x == std.math.minInt(i64)) return 64; - return Type.smallestUnsignedBits(@intCast(u64, -x - 1)) + 1; + return Type.smallestUnsignedBits(@intCast(u64, -(x + 1))) + 1; }, .u64 => |x| { return Type.smallestUnsignedBits(x) + @boolToInt(sign); -- cgit v1.2.3