From 5e989fcb679215a6357dd35b5b8903293f963846 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 18 Aug 2022 22:02:10 -0700 Subject: [PATCH] stage2: pointers to comptime-only types are comptime-only This is a partial revert of c5ba941b77fbdb06841f28142420c6786f2a4d0c. --- src/type.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/type.zig b/src/type.zig index 6a66fb9d70..f6afa33df1 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2374,6 +2374,10 @@ pub const Type = extern union { .error_union, .error_set, .error_set_merged, + => return true, + + // Pointers to zero-bit types still have a runtime address; however, pointers + // to comptime-only types do not, with the exception of function pointers. .anyframe_T, .optional_single_mut_pointer, .optional_single_const_pointer, @@ -2386,7 +2390,17 @@ pub const Type = extern union { .const_slice, .mut_slice, .pointer, - => return true, + => { + if (ignore_comptime_only) { + return true; + } else if (ty.childType().zigTypeTag() == .Fn) { + return true; + } else if (sema_kit) |sk| { + return !(try sk.sema.typeRequiresComptime(sk.block, sk.src, ty)); + } else { + return !comptimeOnly(ty); + } + }, // These are false because they are comptime-only types. .single_const_pointer_to_comptime_int,