mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-23 07:57:52 +00:00
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)
This commit is contained in:
+8
-2
@@ -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; \
|
||||
}) \
|
||||
|
||||
Reference in New Issue
Block a user