aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-09-16 00:10:42 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-09-15 21:46:38 -0700
commit6df78c3bc17e5922792fcef0025043c358daa52f (patch)
tree08cef0a28f498b9bd946714d4bc91ddf284fa166 /src/type.zig
parent61b70778bdf975957d45432987dde16029aca69a (diff)
downloadzig-6df78c3bc17e5922792fcef0025043c358daa52f.tar.gz
zig-6df78c3bc17e5922792fcef0025043c358daa52f.zip
Sema: mark pointers to inline functions as comptime-only
This is supposed to be the case, similar to how pointers to generic functions are comptime-only (several pieces of logic already assumed this). These types being considered runtime was causing `dbg_var_val` AIR instructions to be wrongly emitted for such values, causing codegen backends to create a runtime reference to the inline function, which (at least on the LLVM backend) triggers an error. Resolves: #38
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/type.zig b/src/type.zig
index 67f855806f..32d207bfbf 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -467,12 +467,10 @@ pub const Type = struct {
.empty_struct_type => false,
else => switch (ip.indexToKey(ty.toIntern())) {
.int_type => |int_type| int_type.bits != 0,
- .ptr_type => |ptr_type| {
+ .ptr_type => {
// Pointers to zero-bit types still have a runtime address; however, pointers
// to comptime-only types do not, with the exception of function pointers.
if (ignore_comptime_only) return true;
- const child_ty = ptr_type.child.toType();
- if (child_ty.zigTypeTag(mod) == .Fn) return !mod.typeToFunc(child_ty).?.is_generic;
if (strat == .sema) return !(try strat.sema.typeRequiresComptime(ty));
return !comptimeOnly(ty, mod);
},
@@ -2649,7 +2647,7 @@ pub const Type = struct {
.ptr_type => |ptr_type| {
const child_ty = ptr_type.child.toType();
switch (child_ty.zigTypeTag(mod)) {
- .Fn => return mod.typeToFunc(child_ty).?.is_generic,
+ .Fn => return !child_ty.isFnOrHasRuntimeBits(mod),
.Opaque => return false,
else => return child_ty.comptimeOnly(mod),
}