aboutsummaryrefslogtreecommitdiff
path: root/src/parser.hpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-03-24 11:55:03 +0000
committergingerBill <bill@gingerbill.org>2022-03-24 11:55:03 +0000
commit3f935bea2505b3ee7e169a29b7aed50c0e5614b7 (patch)
tree3d3886ccfe8146a2226703c1d10b7908f3b54e3b /src/parser.hpp
parent3e66eec7354a8248fe8e0edfccbdc9e8b203e88a (diff)
`union #shared_nil`
This adds a feature to `union` which requires all the variants to have a `nil` value and on assign to the union, checks whether that value is `nil` or not. If the value is `nil`, the union will be `nil` (thus sharing the `nil` value)
Diffstat (limited to 'src/parser.hpp')
-rw-r--r--src/parser.hpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parser.hpp b/src/parser.hpp
index c33d1520b..c7b4fd0d8 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -330,6 +330,13 @@ char const *inline_asm_dialect_strings[InlineAsmDialect_COUNT] = {
"intel",
};
+enum UnionTypeKind : u8 {
+ UnionType_Normal = 0,
+ UnionType_maybe = 1,
+ UnionType_no_nil = 2,
+ UnionType_shared_nil = 3,
+};
+
#define AST_KINDS \
AST_KIND(Ident, "identifier", struct { \
Token token; \
@@ -678,8 +685,7 @@ AST_KIND(_TypeBegin, "", bool) \
Slice<Ast *> variants; \
Ast *polymorphic_params; \
Ast * align; \
- bool maybe; \
- bool no_nil; \
+ UnionTypeKind kind; \
Token where_token; \
Slice<Ast *> where_clauses; \
}) \