aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-25 19:41:19 -0400
committerGitHub <noreply@github.com>2021-10-25 19:41:19 -0400
commitdf198ea60e05664b5b72a43aae815fa06d94c19c (patch)
treeedf13ce2d73ab17a56d6b07b4734b97260bde3eb /src/type.zig
parent30d01c8fea68baab396081da040f49defa494088 (diff)
parent21bf3b80666c14c9b2a2e1ec984a6b4bb23a5bb7 (diff)
downloadzig-df198ea60e05664b5b72a43aae815fa06d94c19c.tar.gz
zig-df198ea60e05664b5b72a43aae815fa06d94c19c.zip
Merge pull request #10034 from Snektron/stage2-slice
stage2: slice and optional improvements
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/type.zig b/src/type.zig
index 4682b3ed10..ca18b182a6 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2347,11 +2347,13 @@ pub const Type = extern union {
}
}
- /// Asserts that the type is an optional
+ /// Asserts that the type is an optional or a pointer that can be null.
pub fn isPtrLikeOptional(self: Type) bool {
switch (self.tag()) {
.optional_single_const_pointer,
.optional_single_mut_pointer,
+ .c_const_pointer,
+ .c_mut_pointer,
=> return true,
.optional => {
@@ -2367,6 +2369,8 @@ pub const Type = extern union {
.Many, .One => return !info.@"allowzero",
}
},
+
+ .pointer => return self.castTag(.pointer).?.data.size == .C,
else => unreachable,
}
}