aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-07-22 13:07:32 +0300
committerGitHub <noreply@github.com>2022-07-22 13:07:32 +0300
commit8e75ba653b03477229cf72211e8a8bfe7b071254 (patch)
tree4689ba96ff2ba3090d83c8b8c27f3f61ae34df92 /src/type.zig
parent460211431f407c9f707e3ac3bbff61610a487926 (diff)
parentb749487f48cad2dd779d7fa6d0afcafc975ba26c (diff)
downloadzig-8e75ba653b03477229cf72211e8a8bfe7b071254.tar.gz
zig-8e75ba653b03477229cf72211e8a8bfe7b071254.zip
Merge pull request #12117 from Vexu/stage2-compile-errors
Stage2: explain why value must be comptime known
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig
index 59f0668770..bdddaab070 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -4643,13 +4643,27 @@ pub const Type = extern union {
}
/// Asserts the type is a function.
- pub fn fnCallingConventionAllowsZigTypes(self: Type) bool {
- return switch (self.fnCallingConvention()) {
+ pub fn fnCallingConventionAllowsZigTypes(cc: std.builtin.CallingConvention) bool {
+ return switch (cc) {
.Unspecified, .Async, .Inline, .PtxKernel => true,
else => false,
};
}
+ pub fn isValidParamType(self: Type) bool {
+ return switch (self.zigTypeTagOrPoison() catch return true) {
+ .Undefined, .Null, .Opaque, .NoReturn => false,
+ else => true,
+ };
+ }
+
+ pub fn isValidReturnType(self: Type) bool {
+ return switch (self.zigTypeTagOrPoison() catch return true) {
+ .Undefined, .Null, .Opaque => false,
+ else => true,
+ };
+ }
+
/// Asserts the type is a function.
pub fn fnIsVarArgs(self: Type) bool {
return switch (self.tag()) {
@@ -5650,6 +5664,10 @@ pub const Type = extern union {
const union_obj = ty.cast(Payload.Union).?.data;
return union_obj.srcLoc(mod);
},
+ .@"opaque" => {
+ const opaque_obj = ty.cast(Payload.Opaque).?.data;
+ return opaque_obj.srcLoc(mod);
+ },
.atomic_order,
.atomic_rmw_op,
.calling_convention,