authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-02-28 11:58:23+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:14+00:00
logc64755fb2f3178b4f593ef9f2cb54beef03af36f
tree2d0cad90a5b52d2621bbd6b8ecdf207994f2ecd8
parent978f7fb1ff1cdb36f48b774516aa09ab6a1dfbc0
signaturelock-open Commit is signed but in an unrecognized format.

Type: fix assertion failure


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

src/Type.zig+10-7
......@@ -3094,7 +3094,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
30943094 if (ty.isSlice(zcu)) return false;
30953095 const child_ty = ty.childType(zcu);
30963096 if (child_ty.zigTypeTag(zcu) == .@"fn") {
3097 return ty.isConstPtr(zcu) and child_ty.validateExtern(.other, zcu);
3097 return ty.isConstPtr(zcu) and validateExternCallconv(child_ty.fnCallingConvention(zcu));
30983098 }
30993099 return true;
31003100 },
......@@ -3104,12 +3104,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
31043104 },
31053105 .@"fn" => {
31063106 if (position != .other) return false;
3107 // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.
3108 // The goal is to experiment with more integrated CPU/GPU code.
3109 if (ty.fnCallingConvention(zcu) == .nvptx_kernel) {
3110 return true;
3111 }
3112 return !target_util.fnCallConvAllowsZigTypes(ty.fnCallingConvention(zcu));
3107 return validateExternCallconv(ty.fnCallingConvention(zcu));
31133108 },
31143109 .@"enum" => {
31153110 const enum_obj = zcu.intern_pool.loadEnumType(ty.toIntern());
......@@ -3155,6 +3150,14 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool
31553150 .optional => ty.isPtrLikeOptional(zcu),
31563151 };
31573152}
3153fn validateExternCallconv(cc: std.builtin.CallingConvention) bool {
3154 return switch (cc) {
3155 // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.
3156 // The goal is to experiment with more integrated CPU/GPU code.
3157 .nvptx_kernel => true,
3158 else => !target_util.fnCallConvAllowsZigTypes(cc),
3159 };
3160}
31583161
31593162/// Asserts that `ty` has resolved layout.
31603163pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void {