aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-02-28 10:09:23 +0200
committerAndrew Kelley <andrew@ziglang.org>2022-02-28 13:09:14 -0700
commitdfeffcfbf825c29d89ccec281ab95dd2383317ac (patch)
tree64b86ad830e83fea4b1acf27e5aef17e265f66f4 /src/type.zig
parent3a65fa269f476ecb9dafd8be77ee9f9c0c4ba996 (diff)
downloadzig-dfeffcfbf825c29d89ccec281ab95dd2383317ac.tar.gz
zig-dfeffcfbf825c29d89ccec281ab95dd2383317ac.zip
stage2: tuple mul/cat
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/type.zig b/src/type.zig
index a84a0f4520..fb3ab5d28f 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -4531,7 +4531,15 @@ pub const Type = extern union {
};
pub fn isTuple(ty: Type) bool {
- return ty.tag() == .tuple;
+ return ty.tag() == .tuple or ty.tag() == .empty_struct_literal;
+ }
+
+ pub fn tupleFields(ty: Type) Payload.Tuple.Data {
+ return switch (ty.tag()) {
+ .tuple => ty.castTag(.tuple).?.data,
+ .empty_struct_literal => .{ .types = &.{}, .values = &.{} },
+ else => unreachable,
+ };
}
/// The sub-types are named after what fields they contain.
@@ -4683,11 +4691,13 @@ pub const Type = extern union {
pub const Tuple = struct {
base: Payload = .{ .tag = .tuple },
- data: struct {
+ data: Data,
+
+ pub const Data = struct {
types: []Type,
/// unreachable_value elements are used to indicate runtime-known.
values: []Value,
- },
+ };
};
pub const Union = struct {