aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-05 18:35:08 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:42:28 -0700
commit08e97639513f09e2797bd7afcdfdfecdad6c6fd8 (patch)
tree7917c0dc5444809b0e6a2b5a364785f9f8710b85 /src/type.zig
parent80bf5af3458b25ae7375b548dc7f42150fbef3c8 (diff)
downloadzig-08e97639513f09e2797bd7afcdfdfecdad6c6fd8.tar.gz
zig-08e97639513f09e2797bd7afcdfdfecdad6c6fd8.zip
stage2: add missing comptimeOnly logic for InternPool
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/type.zig b/src/type.zig
index cbc0b5bcea..a51ae273c1 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -4076,11 +4076,18 @@ pub const Type = struct {
pub fn comptimeOnly(ty: Type, mod: *const Module) bool {
if (ty.ip_index != .none) return switch (mod.intern_pool.indexToKey(ty.ip_index)) {
.int_type => false,
- .ptr_type => @panic("TODO"),
- .array_type => |array_type| return array_type.child.toType().comptimeOnly(mod),
- .vector_type => |vector_type| return vector_type.child.toType().comptimeOnly(mod),
- .opt_type => @panic("TODO"),
- .error_union_type => @panic("TODO"),
+ .ptr_type => |ptr_type| {
+ const child_ty = ptr_type.elem_type.toType();
+ if (child_ty.zigTypeTag(mod) == .Fn) {
+ return false;
+ } else {
+ return child_ty.comptimeOnly(mod);
+ }
+ },
+ .array_type => |array_type| array_type.child.toType().comptimeOnly(mod),
+ .vector_type => |vector_type| vector_type.child.toType().comptimeOnly(mod),
+ .opt_type => |child| child.toType().comptimeOnly(mod),
+ .error_union_type => |error_union_type| error_union_type.payload_type.toType().comptimeOnly(mod),
.simple_type => |t| switch (t) {
.f16,
.f32,