mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 20:48:04 +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:
@@ -10047,8 +10047,11 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) {
|
||||
str = write_expr_to_string(str, st->polymorphic_params, shorthand);
|
||||
str = gb_string_appendc(str, ") ");
|
||||
}
|
||||
if (st->no_nil) str = gb_string_appendc(str, "#no_nil ");
|
||||
if (st->maybe) str = gb_string_appendc(str, "#maybe ");
|
||||
switch (st->kind) {
|
||||
case UnionType_maybe: str = gb_string_appendc(str, "#maybe "); break;
|
||||
case UnionType_no_nil: str = gb_string_appendc(str, "#no_nil "); break;
|
||||
case UnionType_shared_nil: str = gb_string_appendc(str, "#shared_nil "); break;
|
||||
}
|
||||
if (st->align) {
|
||||
str = gb_string_appendc(str, "#align ");
|
||||
str = write_expr_to_string(str, st->align, shorthand);
|
||||
|
||||
Reference in New Issue
Block a user