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(...@@ -932,7 +932,9 @@ pub fn abiAlignmentAdvanced(
932 if (vector_type.len == 0) return .{ .scalar = .@"1" };932 if (vector_type.len == 0) return .{ .scalar = .@"1" };
933 switch (mod.comp.getZigBackend()) {933 switch (mod.comp.getZigBackend()) {
934 else => {934 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));
936 if (elem_bits == 0) return .{ .scalar = .@"1" };938 if (elem_bits == 0) return .{ .scalar = .@"1" };
937 const bytes = ((elem_bits * vector_type.len) + 7) / 8;939 const bytes = ((elem_bits * vector_type.len) + 7) / 8;
938 const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);940 const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);
...@@ -2829,7 +2831,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve...@@ -2829,7 +2831,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
2829 .no, .wip => false,2831 .no, .wip => false,
2830 .yes => true,2832 .yes => true,
2831 .unknown => {2833 .unknown => {
2832 assert(strat == .sema);2834 // Inlined `assert` so that the resolution calls below are not statically reachable.
2835 if (strat != .sema) unreachable;
28332836
2834 if (struct_type.flagsUnordered(ip).field_types_wip) {2837 if (struct_type.flagsUnordered(ip).field_types_wip) {
2835 struct_type.setRequiresComptime(ip, .unknown);2838 struct_type.setRequiresComptime(ip, .unknown);
...@@ -2874,7 +2877,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve...@@ -2874,7 +2877,8 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
2874 .no, .wip => return false,2877 .no, .wip => return false,
2875 .yes => return true,2878 .yes => return true,
2876 .unknown => {2879 .unknown => {
2877 assert(strat == .sema);2880 // Inlined `assert` so that the resolution calls below are not statically reachable.
2881 if (strat != .sema) unreachable;
28782882
2879 if (union_type.flagsUnordered(ip).status == .field_types_wip) {2883 if (union_type.flagsUnordered(ip).status == .field_types_wip) {
2880 union_type.setRequiresComptime(ip, .unknown);2884 union_type.setRequiresComptime(ip, .unknown);