mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
union #no_nil
This commit is contained in:
+7
-1
@@ -1326,8 +1326,14 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
|
||||
case i64: tag = i64(i);
|
||||
case: panic("Invalid union tag type");
|
||||
}
|
||||
assert(tag >= 0);
|
||||
|
||||
if v.data == nil || tag == 0 {
|
||||
if v.data == nil {
|
||||
strings.write_string(fi.buf, "nil");
|
||||
} else if info.no_nil {
|
||||
id := info.variants[tag].id;
|
||||
fmt_arg(fi, any{v.data, id}, verb);
|
||||
} else if tag == 0 {
|
||||
strings.write_string(fi.buf, "nil");
|
||||
} else {
|
||||
id := info.variants[tag-1].id;
|
||||
|
||||
@@ -86,10 +86,11 @@ Type_Info_Struct :: struct {
|
||||
custom_align: bool,
|
||||
};
|
||||
Type_Info_Union :: struct {
|
||||
variants: []^Type_Info,
|
||||
tag_offset: uintptr,
|
||||
tag_type: ^Type_Info,
|
||||
variants: []^Type_Info,
|
||||
tag_offset: uintptr,
|
||||
tag_type: ^Type_Info,
|
||||
custom_align: bool,
|
||||
no_nil: bool,
|
||||
};
|
||||
Type_Info_Enum :: struct {
|
||||
base: ^Type_Info,
|
||||
|
||||
Reference in New Issue
Block a user