mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-07 11:04:17 +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:
@@ -619,9 +619,11 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
||||
case Type_Union:
|
||||
doc_type.kind = OdinDocType_Union;
|
||||
if (type->Union.is_polymorphic) { doc_type.flags |= OdinDocTypeFlag_Union_polymorphic; }
|
||||
if (type->Union.no_nil) { doc_type.flags |= OdinDocTypeFlag_Union_no_nil; }
|
||||
if (type->Union.maybe) { doc_type.flags |= OdinDocTypeFlag_Union_maybe; }
|
||||
|
||||
switch (type->Union.kind) {
|
||||
case UnionType_maybe: doc_type.flags |= OdinDocTypeFlag_Union_maybe; break;
|
||||
case UnionType_no_nil: doc_type.flags |= OdinDocTypeFlag_Union_no_nil; break;
|
||||
case UnionType_shared_nil: doc_type.flags |= OdinDocTypeFlag_Union_shared_nil; break;
|
||||
}
|
||||
{
|
||||
auto variants = array_make<OdinDocTypeIndex>(heap_allocator(), type->Union.variants.count);
|
||||
defer (array_free(&variants));
|
||||
|
||||
Reference in New Issue
Block a user