authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-15 20:01:17+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-16 11:38:20+01:00
log67cd14dbdbf2ce435a2bd81dc82d167b99fad6e3
treee7ad255e2bba446521dd6afa7963fbea1fcd0b3e
parentb1d3d48f687a3a73be1d9ab85035cbdc58e2bb1b
signaturelock-open Commit is signed but in an unrecognized format.

Type: avoid incorrect type resolution calls


1 files changed, 7 insertions(+), 3 deletions(-)

src/Type.zig+7-3
......@@ -932,7 +932,9 @@ pub fn abiAlignmentAdvanced(
932932 if (vector_type.len == 0) return .{ .scalar = .@"1" };
933933 switch (mod.comp.getZigBackend()) {
934934 else => {
935 const elem_bits: u32 = @intCast(try Type.fromInterned(vector_type.child).bitSizeAdvanced(pt, .sema));
935 // This is fine because the child type of a vector always has a bit-size known
936 // without needing any type resolution.
937 const elem_bits: u32 = @intCast(Type.fromInterned(vector_type.child).bitSize(pt));
936938 if (elem_bits == 0) return .{ .scalar = .@"1" };
937939 const bytes = ((elem_bits * vector_type.len) + 7) / 8;
938940 const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);
......@@ -2829,7 +2831,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
28292831 .no, .wip => false,
28302832 .yes => true,
28312833 .unknown => {
2832 assert(strat == .sema);
2834 // Inlined `assert` so that the resolution calls below are not statically reachable.
2835 if (strat != .sema) unreachable;
28332836
28342837 if (struct_type.flagsUnordered(ip).field_types_wip) {
28352838 struct_type.setRequiresComptime(ip, .unknown);
......@@ -2874,7 +2877,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
28742877 .no, .wip => return false,
28752878 .yes => return true,
28762879 .unknown => {
2877 assert(strat == .sema);
2880 // Inlined `assert` so that the resolution calls below are not statically reachable.
2881 if (strat != .sema) unreachable;
28782882
28792883 if (union_type.flagsUnordered(ip).status == .field_types_wip) {
28802884 union_type.setRequiresComptime(ip, .unknown);